diff --git a/bi/case.js b/bi/case.js index ca2452851..1f5a3faf1 100644 --- a/bi/case.js +++ b/bi/case.js @@ -12033,6 +12033,19 @@ BI.DisplayTree = BI.inherit(BI.TreeView, { return setting; }, + _dealWidthNodes: function (nodes) { + nodes = BI.DisplayTree.superclass._dealWidthNodes.apply(this, arguments); + var self = this, o = this.options; + BI.each(nodes, function (i, node) { + if (node.count > 0) { + node.text = node.value + "(" + BI.i18nText("BI-Basic_Altogether") + node.count + BI.i18nText("BI-Basic_Count") + ")"; + } else { + node.text = node.value; + } + }); + return nodes; + }, + initTree: function (nodes, setting) { var setting = setting || this._configSetting(); this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes); diff --git a/bi/core.css b/bi/core.css index 151794401..b09047d83 100644 --- a/bi/core.css +++ b/bi/core.css @@ -3900,7 +3900,7 @@ i { .bi-list-item-none:hover, .bi-list-item-none.hover { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-list-item-none:hover .bi-input, .bi-list-item-none.hover .bi-input { @@ -3913,7 +3913,7 @@ i { .bi-list-item-none:active, .bi-list-item-none.active { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-list-item-none:active .bi-input, .bi-list-item-none.active .bi-input { @@ -3951,7 +3951,7 @@ i { .bi-theme-dark .bi-list-item-none:hover, .bi-theme-dark .bi-list-item-none.hover { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-theme-dark .bi-list-item-none:hover .bi-input, .bi-theme-dark .bi-list-item-none.hover .bi-input { @@ -3964,7 +3964,7 @@ i { .bi-theme-dark .bi-list-item-none:active, .bi-theme-dark .bi-list-item-none.active { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-theme-dark .bi-list-item-none:active .bi-input, .bi-theme-dark .bi-list-item-none.active .bi-input { diff --git a/bi/polyfill.js b/bi/polyfill.js index 1da80799f..f493c89a5 100644 --- a/bi/polyfill.js +++ b/bi/polyfill.js @@ -1,93 +1,93 @@ -if(![].indexOf){ - /** - * 检查指定的值是否在数组中 - * @param {Object} o 要检查的值 - * @return {Number} o在数组中的索引(如果不在数组中则返回-1) - */ - Array.prototype.indexOf = function (o) { - for (var i = 0, len = this.length; i < len; i++) { - if (_.isEqual(o, this[i])) { - return i; - } - } - return -1; - } -} -if(![].lastIndexOf){ - /** - * 检查指定的值是否在数组中 - * ie67不支持数组的这个方法 - * @param {Object} o 要检查的值 - * @return {Number} o在数组中的索引(如果不在数组中则返回-1) - */ - Array.prototype.lastIndexOf = function (o) { - for (var len = this.length, i = len - 1; i >= 0; i--) { - if (_.isEqual(o, this[i])) { - return i; - } - } - return -1; - } -}/** - * 特殊情况 - * Created by wang on 15/6/23. - */ -//解决console未定义问题 guy -window.console = window.console || (function () { - var c = {}; - c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile - = c.clear = c.exception = c.trace = c.assert = function () { - }; - return c; - })(); -/* - * 前端缓存 - */ -window.localStorage || (window.localStorage = { - items: {}, - setItem: function (k, v) { - BI.Cache.addCookie(k, v); - }, - getItem: function (k) { - return BI.Cache.getCookie(k); - }, - removeItem: function (k) { - BI.Cache.deleteCookie(k); - }, - key: function () { - - }, - clear: function () { - this.items = {}; - } -});//修复ie9下sort方法的bug -!function (window) { - var ua = window.navigator.userAgent.toLowerCase(), - reg = /msie|applewebkit.+safari/; - if (reg.test(ua)) { - var _sort = Array.prototype.sort; - Array.prototype.sort = function (fn) { - if (!!fn && typeof fn === 'function') { - if (this.length < 2) { - return this; - } - var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0; - for (; i < l; i++) { - for (j = i + 1; j < l; j++) { - t = fn.call(this, this[i], this[j]); - r = (typeof t === 'number' ? t : - !!t ? 1 : 0) > 0; - if (r === true) { - tmp = this[i]; - this[i] = this[j]; - this[j] = tmp; - } - } - } - return this; - } else { - return _sort.call(this); - } - }; - } +if(![].indexOf){ + /** + * 检查指定的值是否在数组中 + * @param {Object} o 要检查的值 + * @return {Number} o在数组中的索引(如果不在数组中则返回-1) + */ + Array.prototype.indexOf = function (o) { + for (var i = 0, len = this.length; i < len; i++) { + if (_.isEqual(o, this[i])) { + return i; + } + } + return -1; + } +} +if(![].lastIndexOf){ + /** + * 检查指定的值是否在数组中 + * ie67不支持数组的这个方法 + * @param {Object} o 要检查的值 + * @return {Number} o在数组中的索引(如果不在数组中则返回-1) + */ + Array.prototype.lastIndexOf = function (o) { + for (var len = this.length, i = len - 1; i >= 0; i--) { + if (_.isEqual(o, this[i])) { + return i; + } + } + return -1; + } +}/** + * 特殊情况 + * Created by wang on 15/6/23. + */ +//解决console未定义问题 guy +window.console = window.console || (function () { + var c = {}; + c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile + = c.clear = c.exception = c.trace = c.assert = function () { + }; + return c; + })(); +/* + * 前端缓存 + */ +window.localStorage || (window.localStorage = { + items: {}, + setItem: function (k, v) { + BI.Cache.addCookie(k, v); + }, + getItem: function (k) { + return BI.Cache.getCookie(k); + }, + removeItem: function (k) { + BI.Cache.deleteCookie(k); + }, + key: function () { + + }, + clear: function () { + this.items = {}; + } +});//修复ie9下sort方法的bug +!function (window) { + var ua = window.navigator.userAgent.toLowerCase(), + reg = /msie|applewebkit.+safari/; + if (reg.test(ua)) { + var _sort = Array.prototype.sort; + Array.prototype.sort = function (fn) { + if (!!fn && typeof fn === 'function') { + if (this.length < 2) { + return this; + } + var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0; + for (; i < l; i++) { + for (j = i + 1; j < l; j++) { + t = fn.call(this, this[i], this[j]); + r = (typeof t === 'number' ? t : + !!t ? 1 : 0) > 0; + if (r === true) { + tmp = this[i]; + this[i] = this[j]; + this[j] = tmp; + } + } + } + return this; + } else { + return _sort.call(this); + } + }; + } }(window); \ No newline at end of file diff --git a/bi/widget.js b/bi/widget.js index 6ada13256..8d7b66d04 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -1,3 +1,4 @@ +<<<<<<< HEAD /** * * Created by GUY on 2016/5/26. @@ -16638,4 +16639,16152 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, { } }); BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; +======= +/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableTreeNumber + * @extends BI.Widget + */ +BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-tree-number", + isNeedFreeze: false, + startSequence: 1,//开始的序号 + scrollTop: 0, + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: null, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.vCurr = 1; + this.hCurr = 1; + this.tasks = []; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: this._getHeaderHeight() - 2 + }, {el: {type: "bi.layout"}, height: 2}, { + el: this.scrollContainer + }] + }); + //缓存第一行对应的序号 + this.start = this.options.startSequence; + this.cache = {}; + this._nextState(); + + this._populate(); + }, + + _getNextSequence: function (nodes) { + var self = this; + var start = this.start; + var cnt = this.start; + + function track(node) { + //如果已经有缓存了就不改计数了,复杂表会出现这种情况 + self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt); + cnt++; + } + + BI.each(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = cnt = self.cache[child.text || child.value]; + } + } + track(child) + }); + } + }); + this.start = cnt; + return start; + }, + + _getStart: function (nodes) { + var self = this; + var start = this.start; + BI.some(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = self.cache[child.text || child.value]; + return true; + } + } + }); + } + }); + return start; + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount(node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = this._getHeaderHeight() - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _getHeaderHeight: function () { + var o = this.options; + return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0)); + }, + + _nextState: function () { + var o = this.options; + this._getNextSequence(o.items); + }, + + _prevState: function () { + var self = this, o = this.options; + var firstChild; + BI.some(o.items, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (j, child) { + firstChild = child; + return true; + }); + } + }); + if (firstChild && BI.isNotEmptyObject(this.cache)) { + this.start = this.cache[firstChild.text || firstChild.value]; + } else { + this.start = 1; + } + this._nextState(); + }, + + _getMaxScrollTop: function (numbers) { + var cnt = 0; + BI.each(numbers, function (i, number) { + cnt += number.cnt; + }); + return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth()); + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + + var renderedCells = [], renderedKeys = []; + var numbers = this._formatNumber(o.items); + var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0); + BI.each(numbers, function (i, number) { + intervalTree.set(i, number.height); + }); + var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers)); + var index = intervalTree.greatestLowerBound(scrollTop); + var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0)); + var height = offsetTop; + var bodyHeight = o.height - this._getHeaderHeight(); + while (height < bodyHeight && index < numbers.length) { + renderedKeys.push(index); + offsetTop += numbers[index].height; + height += numbers[index].height; + index++; + } + + BI.each(renderedKeys, function (i, key) { + var index = BI.deepIndexOf(self.renderedKeys, key); + if (index > -1) { + if (numbers[key].height !== self.renderedCells[index]._height) { + self.renderedCells[index]._height = numbers[key].height; + self.renderedCells[index].el.setHeight(numbers[key].height); + } + if (numbers[key].top !== self.renderedCells[index].top) { + self.renderedCells[index].top = numbers[key].top; + self.renderedCells[index].el.element.css("top", numbers[key].top + "px"); + } + renderedCells.push(self.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + styleGetter: numbers[key].isSummary === true ? function () { + return o.summaryCellStyleGetter(true); + } : function (key) { + return function () { + return o.sequenceCellStyleGetter(key); + } + }(numbers[key].index) + }, numbers[key])); + renderedCells.push({ + el: child, + left: 0, + top: numbers[key].top, + _height: numbers[key].height + }); + } + }); + + //已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]) + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + + this.container.setHeight(intervalTree.sumUntil(numbers.length)); + }, + + _restore: function () { + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + _populate: function () { + var self = this; + BI.each(this.tasks, function (i, task) { + task.apply(self); + }); + this.tasks = []; + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + if (v <= 1) { + this.cache = {}; + this.start = this.options.startSequence; + this._restore(); + this.tasks.push(this._nextState); + } else if (v === this.vCurr + 1) { + this.tasks.push(this._nextState); + } else if (v === this.vCurr - 1) { + this.tasks.push(this._prevState); + } + this.vCurr = v; + }, + + setHPage: function (v) { + if (v !== this.hCurr) { + this.tasks.push(this._prevState); + } + this.hCurr = v; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + this.tasks.push(this._prevState); + } + if (header && header !== this.options.header) { + o.header = header; + } + if (crossItems && crossItems !== this.options.crossItems) { + o.crossItems = crossItems; + } + if (crossHeader && crossHeader !== this.options.crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + } +}); +BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/** + * 自适应布局 + * + * 1、resize + * 2、吸附 + * 3、当前组件在最上方 + * 4、可以撤销 + * 5、上下之间插入组件 + * + * Created by GUY on 2016/2/23. + * @class BI.AdaptiveArrangement + * @extends BI.Widget + */ +BI.AdaptiveArrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-adaptive-arrangement", + resizable: true, + layoutType: BI.Arrangement.LAYOUT_TYPE.FREE, + items: [] + }); + }, + + _init: function () { + BI.AdaptiveArrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.arrangement", + element: this, + layoutType: o.layoutType, + items: o.items + }); + this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () { + self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments); + }); + this.zIndex = 0; + BI.each(o.items, function (i, item) { + self._initResizable(item.el); + }); + + $(document).mousedown(function (e) { + BI.each(self.getAllRegions(), function (i, region) { + if (region.el.element.find(e.target).length === 0) { + region.el.element.removeClass("selected"); + } + }); + }); + BI.ResizeDetector.addResizeListener(this, function () { + self.arrangement.resize(); + self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); + }); + }, + + _isEqual: function () { + return this.arrangement._isEqual.apply(this.arrangement, arguments); + }, + + _setSelect: function (item) { + if (!item.element.hasClass("selected")) { + item.element.css("zIndex", ++this.zIndex); + BI.each(this.getAllRegions(), function (i, region) { + region.el.element.removeClass("selected"); + }); + item.element.addClass("selected"); + } + }, + + _initResizable: function (item) { + var self = this, o = this.options; + item.element.css("zIndex", ++this.zIndex); + item.element.mousedown(function () { + self._setSelect(item) + }); + // o.resizable && item.element.resizable({ + // handles: "e, s, se", + // minWidth: 20, + // minHeight: 20, + // autoHide: true, + // helper: "bi-resizer", + // start: function () { + // item.element.css("zIndex", ++self.zIndex); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE); + // }, + // resize: function (e, ui) { + // // self._resize(item.attr("id"), ui.size); + // self._resize(item.attr("id"), e, ui.size, ui.position); + // }, + // stop: function (e, ui) { + // self._stopResize(item.attr("id"), ui.size); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); + // } + // }); + }, + + // _resize: function (name, e, size, position) { + // var self = this; + // this.scrollInterval(e, false, true, function (changedSize) { + // size.width += changedSize.offsetX; + // size.height += changedSize.offsetY; + // var containerWidth = self.arrangement.container.element.width(); + // var containerHeight = self.arrangement.container.element.height(); + // self.arrangement.container.element.width(containerWidth + changedSize.offsetX); + // self.arrangement.container.element.height(containerHeight + changedSize.offsetY); + // switch (self.getLayoutType()) { + // case BI.Arrangement.LAYOUT_TYPE.FREE: + // break; + // case BI.Arrangement.LAYOUT_TYPE.GRID: + // self.setRegionSize(name, size); + // break; + // } + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size); + // }); + // }, + // + // _stopResize: function (name, size) { + // var self = this; + // this.scrollEnd(); + // switch (this.getLayoutType()) { + // case BI.Arrangement.LAYOUT_TYPE.FREE: + // this.setRegionSize(name, size); + // break; + // case BI.Arrangement.LAYOUT_TYPE.GRID: + // this.setRegionSize(name, size); + // break; + // } + // }, + + _getScrollOffset: function () { + return this.arrangement._getScrollOffset(); + }, + + getClientWidth: function () { + return this.arrangement.getClientWidth(); + }, + + getClientHeight: function () { + return this.arrangement.getClientHeight(); + }, + + addRegion: function (region, position) { + this._initResizable(region.el); + this._setSelect(region.el); + var self = this, flag; + var old = this.arrangement.getAllRegions(); + if (flag = this.arrangement.addRegion(region, position)) { + this._old = old; + } + return flag; + }, + + deleteRegion: function (name) { + var flag; + var old = this.getAllRegions(); + if (flag = this.arrangement.deleteRegion(name)) { + this._old = old; + } else { + this._old = this.getAllRegions(); + this.relayout(); + } + return flag; + }, + + setRegionSize: function (name, size) { + var flag; + var old = this.getAllRegions(); + if (flag = this.arrangement.setRegionSize(name, size)) { + this._old = old; + } + return flag; + }, + + setPosition: function (position, size) { + var self = this; + return this.arrangement.setPosition(position, size); + }, + + setRegionPosition: function (name, position) { + var region = this.getRegionByName(name); + return this.arrangement.setRegionPosition(name, position); + }, + + setDropPosition: function (position, size) { + return this.arrangement.setDropPosition(position, size); + }, + + scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { + var self = this; + var map = { + top: [-1, 0], + bottom: [1, 0], + left: [0, -1], + right: [0, 1] + }; + var clientSize = this.element.bounds(); + + function scrollTo(direction, callback) { + if (direction === "") { + self.lastActiveRegion = ""; + if (self._scrollInterval) { + clearInterval(self._scrollInterval); + self._scrollInterval = null; + } + return; + } + if (self.lastActiveRegion !== direction) { + self.lastActiveRegion = direction; + if (self._scrollInterval) { + clearInterval(self._scrollInterval); + self._scrollInterval = null; + } + self._scrollInterval = setInterval(function () { + var offset = self._getScrollOffset(); + var t = offset.top + map[direction][0] * 40; + var l = offset.left + map[direction][1] * 40; + if (t < 0 || l < 0) { + return; + } + callback({ + offsetX: map[direction][1] * 40, + offsetY: map[direction][0] * 40 + }); + self.scrollTo({ + top: t, + left: l + }); + }, 300); + } + } + + cb({ + offsetX: 0, + offsetY: 0 + }); + var offset = this.element.offset(); + var p = { + left: e.pageX - offset.left, + top: e.pageY - offset.top + }; + //向上滚 + if (isBorderScroll && p.top >= 0 && p.top <= 30) { + scrollTo("top", cb) + } + //向下滚 + else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) { + scrollTo("bottom", cb) + } + //向左滚 + else if (isBorderScroll && p.left >= 0 && p.left <= 30) { + scrollTo("left", cb) + } + //向右滚 + else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) { + scrollTo("right", cb) + } else { + if (isOverflowScroll === true) { + if (p.top < 0) { + scrollTo("top", cb); + } + else if (p.top > clientSize.height) { + scrollTo("bottom", cb); + } + else if (p.left < 0) { + scrollTo("left", cb); + } + else if (p.left > clientSize.width) { + scrollTo("right", cb); + } else { + scrollTo("", cb); + } + } else { + scrollTo("", cb); + } + } + }, + + scrollEnd: function () { + this.lastActiveRegion = ""; + if (this._scrollInterval) { + clearInterval(this._scrollInterval); + this._scrollInterval = null; + } + }, + + scrollTo: function (scroll) { + this.arrangement.scrollTo(scroll); + }, + + zoom: function (ratio) { + this.arrangement.zoom(ratio); + }, + + resize: function () { + this.arrangement.resize(); + }, + + relayout: function () { + return this.arrangement.relayout(); + }, + + setLayoutType: function (type) { + var self = this; + this.arrangement.setLayoutType(type); + }, + + getLayoutType: function () { + return this.arrangement.getLayoutType(); + }, + + getLayoutRatio: function () { + return this.arrangement.getLayoutRatio(); + }, + + getHelper: function () { + return this.arrangement.getHelper(); + }, + + getRegionByName: function (name) { + return this.arrangement.getRegionByName(name); + }, + + getAllRegions: function () { + return this.arrangement.getAllRegions(); + }, + + revoke: function () { + if (this._old) { + this.populate(BI.toArray(this._old)); + } + }, + + populate: function (items) { + var self = this; + BI.each(items, function (i, item) { + self._initResizable(item.el); + }); + this.arrangement.populate(items); + } +}); +BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE"; +BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE"; +BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE"; +BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE"; +BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL"; +BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/** + * Arrangement的block面板 + * + * Created by GUY on 2016/3/1. + * @class BI.ArrangementBlock + * @extends BI.Widget + */ +BI.ArrangementBlock = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement-block bi-mask" + }); + } +}); +BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/** + * Arrangement的drop面板 + * + * Created by GUY on 2016/3/1. + * @class BI.ArrangementDroppable + * @extends BI.Widget + */ +BI.ArrangementDroppable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement-droppable bi-resizer" + }); + } +}); +BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/** + * 布局 + * + * Created by GUY on 2016/2/23. + * @class BI.Arrangement + * @extends BI.Widget + */ +BI.Arrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement", + layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, + items: [] + }); + }, + + _init: function () { + BI.Arrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.arrangement_droppable", + cls: "arrangement-block", + invisible: true + }); + this.block = BI.createWidget({ + type: "bi.arrangement_block", + invisible: true + }); + this.container = BI.createWidget({ + type: "bi.absolute", + items: o.items.concat([this.block, this.arrangement]) + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.adaptive", + width: "100%", + height: "100%", + scrollable: true, + items: [this.container] + }); + this.scrollContainer.element.scroll(function () { + self.fireEvent(BI.Arrangement.EVENT_SCROLL, { + scrollLeft: self.scrollContainer.element.scrollLeft(), + scrollTop: self.scrollContainer.element.scrollTop(), + clientWidth: self.scrollContainer.element[0].clientWidth, + clientHeight: self.scrollContainer.element[0].clientHeight + }); + }); + + BI.createWidget({ + type: "bi.adaptive", + element: this, + items: [this.scrollContainer] + }); + this.regions = {}; + if (o.items.length > 0) { + BI.nextTick(function () { + self.populate(o.items); + }); + } + }, + + ////初始化操作//// + _calculateRegions: function (items) { + var self = this, o = this.options; + this.regions = {}; + BI.each(items, function (i, item) { + var region = self._createOneRegion(item); + self.regions[region.id] = region; + }); + }, + + _isEqual: function (num1, num2) { + return Math.abs(num1 - num2) < 2; + }, + + _isLessThan: function (num1, num2) { + return num1 < num2 && !this._isEqual(num1, num2); + }, + + _isMoreThan: function (num1, num2) { + return num1 > num2 && !this._isEqual(num1, num2); + }, + + _isLessThanEqual: function (num1, num2) { + return num1 <= num2 || this._isEqual(num1, num2); + }, + + _isMoreThanEqual: function (num1, num2) { + return num1 >= num2 || this._isEqual(num1, num2); + }, + + //获取占有的最大Region + _getRegionOccupied: function (regions) { + var self = this, o = this.options; + if (BI.size(regions || this.regions) <= 0) { + return { + left: 0, + top: 0, + width: 0, + height: 0 + } + } + var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN; + BI.each(regions || this.regions, function (id, region) { + minLeft = Math.min(minLeft, region.left); + maxLeft = Math.max(maxLeft, region.left + region.width); + minTop = Math.min(minTop, region.top); + maxTop = Math.max(maxTop, region.top + region.height); + }); + return { + left: minLeft, + top: minTop, + width: maxLeft - minLeft, + height: maxTop - minTop + } + }, + + //两个区域的交叉面积 + _getCrossArea: function (region1, region2) { + if (region1.left <= region2.left) { + if (region1.top <= region2.top) { + if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) { + if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) { + return 0; + } + return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left); + } + } else { + if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) { + if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) { + return 0; + } + return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left); + } + } + } else { + if (region1.top <= region2.top) { + if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) { + if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) { + return 0; + } + return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left); + } + } else { + if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) { + if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) { + return 0; + } + return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left); + } + } + } + return 0; + }, + + //是否有覆盖的组件 + _isRegionOverlay: function (regions) { + var reg = []; + BI.each(regions || this.regions, function (id, region) { + reg.push(new BI.Region(region.left, region.top, region.width, region.height)); + }); + for (var i = 0, len = reg.length; i < len; i++) { + for (var j = i + 1; j < len; j++) { + var area1 = { + left: reg[i].x, + top: reg[i].y, + width: reg[i].w, + height: reg[i].h + }; + var area2 = { + left: reg[j].x, + top: reg[j].y, + width: reg[j].w, + height: reg[j].h + }; + if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) { + return true; + } + } + } + return false; + }, + + //布局是否是优良的 + _isArrangeFine: function (regions) { + switch (this.options.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + return true; + case BI.Arrangement.LAYOUT_TYPE.GRID: + // if (this._isRegionOverlay()) { + // return false; + // } + } + return true; + }, + + _getRegionNames: function (regions) { + var names = []; + BI.each(regions || this.regions, function (i, region) { + names.push(region.id || region.attr("id")); + }); + return names; + }, + + _getRegionsByNames: function (names, regions) { + names = BI.isArray(names) ? names : [names]; + regions = regions || this.regions; + if (BI.isArray(regions)) { + var result = []; + BI.each(regions, function (i, region) { + if (names.contains(region.id || region.attr("id"))) { + result.push(region); + } + }); + } else { + var result = {}; + BI.each(names, function (i, name) { + result[name] = regions[name]; + }); + } + return result; + }, + + _cloneRegion: function (regions) { + var clone = {}; + BI.each(regions || this.regions, function (id, region) { + clone[id] = {}; + clone[id].el = region.el; + clone[id].id = region.id; + clone[id].left = region.left; + clone[id].top = region.top; + clone[id].width = region.width; + clone[id].height = region.height; + }); + return clone; + }, + + //测试合法性 + _test: function (regions) { + var self = this; + return !BI.any(regions || this.regions, function (i, region) { + if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) { + return true; + } + }) + }, + + _getScrollOffset: function () { + return { + left: this.scrollContainer.element[0].scrollLeft, + top: this.scrollContainer.element[0].scrollTop + } + }, + + ////操作//// + _createOneRegion: function (item) { + var el = BI.createWidget(item.el); + el.setVisible(true); + return { + id: el.attr("id"), + left: item.left, + top: item.top, + width: item.width, + height: item.height, + el: el + } + }, + + _applyRegion: function (regions) { + var self = this, o = this.options; + BI.each(regions || this.regions, function (i, region) { + region.el.element.css({ + left: region.left, + top: region.top, + width: region.width, + height: region.height + }); + }); + this._applyContainer(); + this.ratio = this.getLayoutRatio(); + }, + + _renderRegion: function () { + var self = this; + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: BI.toArray(this.regions) + }); + }, + + getClientWidth: function () { + return this.scrollContainer.element[0].clientWidth; + }, + + getClientHeight: function () { + return this.scrollContainer.element[0].clientHeight; + }, + + _applyContainer: function () { + //先掩藏后显示能够明确滚动条是否出现 + this.scrollContainer.element.css("overflow", "hidden"); + var occupied = this._getRegionOccupied(); + this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height); + this.scrollContainer.element.css("overflow", "auto"); + return occupied; + }, + + _modifyRegion: function (regions) { + BI.each(this.regions, function (id, region) { + if (regions[id]) { + region.left = regions[id].left; + region.top = regions[id].top; + region.width = regions[id].width; + region.height = regions[id].height; + } + }); + }, + + _addRegion: function (item) { + var region = this._createOneRegion(item); + this.regions[region.id] = region; + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [region] + }); + }, + + _deleteRegionByName: function (name) { + this.regions[name].el.setVisible(false); + delete this.regions[name]; + }, + + _setArrangeSize: function (size) { + this.arrangement.element.css({ + left: size.left, + top: size.top, + width: size.width, + height: size.height + }) + }, + + //Grid + _getOneWidthPortion: function () { + return this.getClientWidth() / BI.Arrangement.PORTION; + }, + _getOneHeightPortion: function () { + return this.getClientHeight() / BI.Arrangement.H_PORTION; + }, + + _getGridPositionAndSize: function (position) { + var perWidth = this._getOneWidthPortion(); + var perHeight = this._getOneHeightPortion(); + var widthPortion = Math.round(position.width / perWidth); + var leftPortion = Math.round(position.left / perWidth); + var topPortion = Math.round(position.top / perHeight); + var heightPortion = Math.round(position.height / perHeight); + // if (leftPortion > BI.Arrangement.PORTION) { + // leftPortion = BI.Arrangement.PORTION; + // } + // if (widthPortion > BI.Arrangement.PORTION) { + // widthPortion = BI.Arrangement.PORTION; + // } + // if (leftPortion + widthPortion > BI.Arrangement.PORTION) { + // leftPortion = BI.Arrangement.PORTION - widthPortion; + // } + if (widthPortion === 0) { + widthPortion = 1; + } + if (heightPortion === 0) { + heightPortion = 1; + } + return { + x: leftPortion, + y: topPortion, + w: widthPortion, + h: heightPortion + } + }, + + _getBlockPositionAndSize: function (position) { + var perWidth = this._getOneWidthPortion(); + var perHeight = this._getOneHeightPortion(); + return { + left: position.x * perWidth, + top: position.y * perHeight, + width: position.w * perWidth, + height: position.h * perHeight + }; + }, + + _getLayoutsByRegions: function (regions) { + var self = this; + var result = []; + BI.each(regions || this.regions, function (id, region) { + result.push(BI.extend(self._getGridPositionAndSize(region), { + i: region.id + })) + }); + return result; + }, + + _getLayoutIndexByName: function (layout, name) { + return BI.findIndex(layout, function (i, l) { + return l.i === name; + }); + }, + + _setBlockPositionAndSize: function (size) { + this.block.element.css({ + left: size.left, + top: size.top, + width: size.width, + height: size.height + }); + }, + + _getRegionsByLayout: function (layout) { + var self = this; + var regions = {}; + BI.each(layout, function (i, ly) { + regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), { + id: ly.i + }); + }); + return regions; + }, + + _setRegionsByLayout: function (regions, layout) { + var self = this; + regions || (regions = this.regions); + BI.each(layout, function (i, ly) { + if (regions[ly.i]) { + BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly)); + } + }); + return regions; + }, + + _moveElement: function (layout, l, x, y, isUserAction) { + var self = this; + if (l._static) { + return layout; + } + + if (l.y === y && l.x === x) { + return layout; + } + + var movingUp = y && l.y > y; + if (typeof x === 'number') { + l.x = x; + } + if (typeof y === 'number') { + l.y = y; + } + l.moved = true; + + var sorted = this._sortLayoutItemsByRowCol(layout); + if (movingUp) { + sorted = sorted.reverse(); + } + var collisions = getAllCollisions(sorted, l); + + for (var i = 0, len = collisions.length; i < len; i++) { + var collision = collisions[i]; + if (collision.moved) { + continue; + } + + if (l.y > collision.y && l.y - collision.y > collision.h / 4) { + continue; + } + + if (collision._static) { + layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction); + } else { + layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction); + } + } + + return layout; + + function getAllCollisions(layout, layoutItem) { + return BI.filter(layout, function (i, l) { + return self._collides(l, layoutItem); + }); + } + }, + + _sortLayoutItemsByRowCol: function (layout) { + return [].concat(layout).sort(function (a, b) { + if (a.y > b.y || (a.y === b.y && a.x > b.x)) { + return 1; + } + return -1; + }); + }, + + _collides: function (l1, l2) { + if (l1 === l2) { + return false; + } // same element + if (l1.x + l1.w <= l2.x) { + return false; + } // l1 is left of l2 + if (l1.x >= l2.x + l2.w) { + return false; + } // l1 is right of l2 + if (l1.y + l1.h <= l2.y) { + return false; + } // l1 is above l2 + if (l1.y >= l2.y + l2.h) { + return false; + } // l1 is below l2 + return true; // boxes overlap + }, + + _getFirstCollision: function (layout, layoutItem) { + for (var i = 0, len = layout.length; i < len; i++) { + if (this._collides(layout[i], layoutItem)) { + return layout[i]; + } + } + }, + + _moveElementAwayFromCollision: function (layout, collidesWith, + itemToMove, isUserAction) { + if (isUserAction) { + var fakeItem = { + x: itemToMove.x, + y: itemToMove.y, + w: itemToMove.w, + h: itemToMove.h, + i: '-1' + }; + fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0); + if (!this._getFirstCollision(layout, fakeItem)) { + return this._moveElement(layout, itemToMove, undefined, fakeItem.y); + } + } + + return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1); + }, + + _compactItem: function (compareWith, l, verticalCompact) { + if (verticalCompact) { + while (l.y > 0 && !this._getFirstCollision(compareWith, l)) { + l.y--; + } + } + + var collides; + while ((collides = this._getFirstCollision(compareWith, l))) { + l.y = collides.y + collides.h; + } + return l; + }, + + compact: function (layout, verticalCompact) { + var compareWith = getStatics(layout); + var sorted = this._sortLayoutItemsByRowCol(layout); + var out = []; + + for (var i = 0, len = sorted.length; i < len; i++) { + var l = sorted[i]; + + if (!l._static) { + l = this._compactItem(compareWith, l, verticalCompact); + + compareWith.push(l); + } + + out[layout.indexOf(l)] = l; + + l.moved = false; + } + + return out; + function getStatics(layout) { + return BI.filter(layout, function (i, l) { + return l._static; + }); + } + }, + + ////公有方法//// + getRegionByName: function (name) { + var obj = {}; + obj[name] = this.regions[name]; + return this._cloneRegion(obj)[name]; + }, + + getAllRegions: function () { + return BI.toArray(this._cloneRegion()); + }, + + getHelper: function () { + var helper = BI.createWidget({ + type: "bi.layout", + width: 18, + height: 18, + cls: "arrangement-helper bi-border" + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [helper] + }); + return helper; + }, + + _start: function () { + if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) { + this.block.setVisible(true); + } else { + this.arrangement.setVisible(true); + } + }, + + _stop: function () { + this.arrangement.setVisible(false); + this.block.setVisible(false); + }, + + ////公有操作//// + setLayoutType: function (type) { + var self = this, o = this.options; + if (type !== o.layoutType) { + o.layoutType = type; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.relayout(); + break; + } + } + }, + + getLayoutType: function () { + return this.options.layoutType; + }, + + getLayoutRatio: function () { + var occupied = this._getRegionOccupied(); + var width = this.getClientWidth(), height = this.getClientHeight(); + return { + x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")), + y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##")) + } + }, + + addRegion: function (region, position) { + if (position) { + this.setPosition(position, region); + } + var self = this, o = this.options; + if (!this.position) { + return false; + } + var test = this._cloneRegion(); + BI.each(this.position.regions, function (i, region) { + test[region.id].left = region.left; + test[region.id].top = region.top; + test[region.id].width = region.width; + test[region.id].height = region.height; + + }); + var item = BI.extend({}, region, { + left: this.position.insert.left, + top: this.position.insert.top, + width: this.position.insert.width, + height: this.position.insert.height + }); + var added = this._createOneRegion(item); + test[added.id] = added; + if (this._test(test)) { + delete test[added.id]; + this._modifyRegion(test); + this._addRegion(item); + this._populate(this.getAllRegions()); + return true; + } + return false; + }, + + deleteRegion: function (name) { + if (!this.regions[name]) { + return false; + } + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + this._deleteRegionByName(name); + this._populate(this.getAllRegions()); + return true; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this._deleteRegionByName(name); + this._populate(this.getAllRegions()); + this.resize(); + return true; + } + return false; + }, + + setRegionSize: function (name, size) { + var self = this, o = this.options; + var flag = false; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var clone = this._cloneRegion(); + BI.extend(clone[name], { + width: size.width, + height: size.height + }); + if (this._test(clone)) { + this._modifyRegion(clone); + flag = true; + } + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + var clone = this._cloneRegion(); + BI.extend(clone[name], { + width: size.width, + height: size.height + }); + if (this._test(clone)) { + var layout = this._getLayoutsByRegions(clone); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + flag = true; + } + break; + } + this._applyRegion(); + return flag; + }, + + setPosition: function (position, size) { + var self = this, o = this.options; + var insert, regions = [], cur; + if (position.left < 0 || position.top < 0) { + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.resize(); + break; + } + this._stop(); + this.position = null; + return null; + } + var offset = this._getScrollOffset(); + position = { + left: position.left + offset.left, + top: position.top + offset.top + }; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var insert = { + top: position.top < 0 ? 0 : position.top, + left: position.left < 0 ? 0 : position.left, + width: size.width, + height: size.height + }; + this.position = { + insert: insert + }; + this._setArrangeSize(insert); + this._start(); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + var p = { + top: position.top < 0 ? 0 : position.top, + left: position.left < 0 ? 0 : position.left, + width: size.width, + height: size.height + }; + this._setArrangeSize(p); + var cur = this._getGridPositionAndSize(p); + var layout = [{ + x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i + }].concat(this._getLayoutsByRegions()); + layout = this._moveElement(layout, layout[0], cur.x, cur.y, true); + layout = this.compact(layout, true); + var regions = this._setRegionsByLayout(this._cloneRegion(), layout); + var insert = this._getBlockPositionAndSize(layout[0]); + this.position = { + insert: insert, + regions: regions + }; + this._applyRegion(regions); + this._setBlockPositionAndSize(insert); + this._start(); + break; + } + return this.position; + }, + + setRegionPosition: function (name, position) { + var self = this, o = this.options; + var offset = this._getScrollOffset(); + position = BI.extend(position, { + left: position.left + offset.left, + top: position.top + offset.top + }); + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + this._applyRegion(); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (!position.stop) { + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + var cloned = this._cloneRegion(); + var cur = this._getGridPositionAndSize(BI.extend(cloned[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + })); + var x = cur.x, y = cur.y; + cur = BI.extend(cur, { + x: 0, y: BI.MAX, i: -1 + }); + delete cloned[name]; + var layout = this._getLayoutsByRegions(cloned); + layout = this._moveElement([cur].concat(layout), cur, x, y, true); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + + this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur)); + this.block.setVisible(true); + } else { + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + var cloned = this._cloneRegion(); + var layout = this._getLayoutsByRegions(cloned); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + this.block.setVisible(false); + } + break; + } + }, + + setDropPosition: function (position, size) { + var self = this; + this.arrangement.setVisible(true); + var offset = this._getScrollOffset(); + this._setArrangeSize(BI.extend({}, size, { + left: position.left + offset.left, + top: position.top + offset.top + })); + return function () { + self.arrangement.setVisible(false); + } + }, + + scrollTo: function (scroll) { + this.scrollContainer.element.scrollTop(scroll.top); + this.scrollContainer.element.scrollLeft(scroll.left); + }, + + zoom: function (ratio) { + var self = this, o = this.options; + if (!ratio) { + return; + } + var occupied = this._applyContainer(); + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + if (this._isArrangeFine()) { + var width = this.getClientWidth(); + var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); + //var yRatio = ratio.y * height / (occupied.top + occupied.height); + var regions = this._cloneRegion(); + BI.each(regions, function (i, region) { + region.left = region.left * xRatio; + //region.top = region.top * yRatio; + region.width = region.width * xRatio; + //region.height = region.height * yRatio; + }); + if (this._test(regions)) { + this._modifyRegion(regions); + this._applyRegion(); + } + this.resize(); + // } else { + this.relayout(); + } + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (this._isArrangeFine()) { + var width = this.getClientWidth(), height = this.getClientHeight(); + var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); + var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height); + var regions = this._cloneRegion(); + BI.each(regions, function (i, region) { + region.left = region.left * xRatio; + region.width = region.width * xRatio; + region.top = region.top * yRatio; + region.height = region.height * yRatio; + //做一下自适应布局到网格布局的兼容 + var perWidth = self._getOneWidthPortion(); + var widthPortion = Math.round(region.width / perWidth); + var leftPortion = Math.round(region.left / perWidth); + var comparePortion = Math.round((region.width + region.left) / perWidth); + if (leftPortion + widthPortion !== comparePortion) { + region.left = leftPortion * perWidth; + region.width = comparePortion * perWidth - region.left; + } + }); + if (this._test(regions)) { + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + } + } else { + this.relayout(); + } + break; + } + }, + + resize: function () { + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.zoom(this.ratio); + var regions = this._cloneRegion(); + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + break; + } + }, + + relayout: function () { + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (!this._isArrangeFine()) { + var perHeight = this._getOneHeightPortion(); + var width = this.getClientWidth(), height = this.getClientHeight(); + var regions = this._cloneRegion(); + var clone = BI.toArray(regions); + clone.sort(function (r1, r2) { + if (self._isEqual(r1.top, r2.top)) { + return r1.left - r2.left; + } + return r1.top - r2.top; + }); + var count = clone.length; + var cols = 4, rows = Math.floor((count - 1) / 4 + 1); + var w = width / cols, h = height / rows; + var store = {}; + BI.each(clone, function (i, region) { + var row = Math.floor(i / 4), col = i % 4; + BI.extend(region, { + top: row * perHeight * 6, + left: col * w, + width: w, + height: perHeight * 6 + }); + if (!store[row]) { + store[row] = {}; + } + store[row][col] = region; + }); + //非4的倍数 + // if (count % 4 !== 0) { + // var lasts = store[rows - 1]; + // var perWidth = width / (count % 4); + // BI.each(lasts, function (i, region) { + // BI.extend(region, { + // left: BI.parseInt(i) * perWidth, + // width: perWidth + // }); + // }); + // } + if (this._test(clone)) { + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._populate(clone); + } + } else { + this.resize(); + } + break; + } + }, + + _populate: function (items) { + this._stop(); + this._calculateRegions(items); + this._applyRegion(); + }, + + populate: function (items) { + var self = this; + BI.each(this.regions, function (name, region) { + self.regions[name].el.setVisible(false); + delete self.regions[name]; + }); + this._populate(items); + this._renderRegion(); + } +}); +BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; +BI.extend(BI.Arrangement, { + PORTION: 36, + H_PORTION: 18, + LAYOUT_TYPE: { + GRID: 0, + FREE: 1 + } +}); +BI.shortcut('bi.arrangement', BI.Arrangement);/** + * 表关联树 + * + * Created by GUY on 2015/12/15. + * @class BI.BranchRelation + * @extends BI.Widget + */ +BI.BranchRelation = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.BranchRelation.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-branch-relation-tree", + items: [], + + centerOffset: 0,//重心偏移量 + direction: BI.Direction.Bottom, + align: BI.VerticalAlign.Top + }) + }, + + _init: function () { + BI.BranchRelation.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + //树分层 + _stratification: function () { + var levels = []; + this.tree.recursion(function (node, route) { + //node.isRoot = route.length <= 1; + node.leaf = node.isLeaf(); + if (!levels[route.length - 1]) { + levels[route.length - 1] = []; + } + levels[route.length - 1].push(node); + }); + return levels; + }, + + //计算所有节点的叶子结点个数 + _calculateLeaves: function () { + var count = 0; + + function track(node) { + var c = 0; + if (node.isLeaf()) { + return 1; + } + BI.each(node.getChildren(), function (i, child) { + c += track(child); + }); + node.set("leaves", c); + return c; + } + + count = track(this.tree.getRoot()); + return count; + }, + + //树平移 + _translate: function (levels) { + var adjust = []; + var maxLevel = levels.length; + BI.each(levels, function (i, nodes) { + if (!adjust[i]) { + adjust[i] = []; + } + BI.each(nodes, function (j, node) { + if (node.isLeaf() && i < maxLevel - 1) { + var newNode = new BI.Node(BI.UUID()); + //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot; + newNode.isNew = true; + //把node向下一层移 + var tar = 0; + if (j > 0) { + var c = nodes[j - 1].getLastChild(); + tar = levels[i + 1].indexOf(c) + 1; + } + levels[i + 1].splice(tar, 0, node); + //新增一个临时树节点 + var index = node.parent.getChildIndex(node.id); + node.parent.removeChildByIndex(index); + node.parent.addChild(newNode, index); + newNode.addChild(node); + adjust[i].push(newNode); + nodes[j] = newNode; + } else { + adjust[i].push(node); + } + }) + }); + return adjust; + }, + + //树补白 + _fill: function (levels) { + var adjust = []; + var maxLevel = levels.length; + BI.each(levels, function (i, nodes) { + if (!adjust[i]) { + adjust[i] = []; + } + BI.each(nodes, function (j, node) { + if (node.isLeaf() && i < maxLevel - 1) { + var newNode = new BI.Node(BI.UUID()); + newNode.leaf = true; + newNode.width = node.width; + newNode.height = node.height; + newNode.isNew = true; + //把node向下一层移 + var tar = 0; + if (j > 0) { + var c = nodes[j - 1].getLastChild(); + tar = levels[i + 1].indexOf(c) + 1; + } + levels[i + 1].splice(tar, 0, newNode); + //新增一个临时树节点 + node.addChild(newNode); + } + adjust[i].push(node); + }) + }); + return adjust; + }, + + //树调整 + _adjust: function (adjust) { + while (true) { + var isAllNeedAjust = false; + BI.backEach(adjust, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (!node.isNew) { + var needAdjust = true; + BI.any(node.getChildren(), function (k, n) { + if (!n.isNew) { + needAdjust = false; + return true; + } + }); + if (!node.isLeaf() && needAdjust === true) { + var allChilds = []; + BI.each(node.getChildren(), function (k, n) { + allChilds = allChilds.concat(n.getChildren()); + }); + node.removeAllChilds(); + BI.each(allChilds, function (k, c) { + node.addChild(c); + }); + var newNode = new BI.Node(BI.UUID()); + //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot; + newNode.isNew = true; + var index = node.parent.getChildIndex(node.id); + node.parent.removeChildByIndex(index); + node.parent.addChild(newNode, index); + newNode.addChild(node); + isAllNeedAjust = true; + } + } + }) + }); + if (isAllNeedAjust === false) { + break; + } else {//树重构 + adjust = this._stratification(); + } + } + return adjust; + }, + + _calculateWidth: function () { + var o = this.options; + var width = 0; + + function track1(node) { + var w = 0; + if (node.isLeaf()) { + return node.width; + } + BI.each(node.getChildren(), function (i, child) { + w += track1(child); + }); + return w; + } + + function track2(node) { + var w = 0; + if (node.isLeaf()) { + return node.height; + } + BI.each(node.getChildren(), function (i, child) { + w += track2(child); + }); + return w; + } + + if (this._isVertical()) { + width = track1(this.tree.getRoot()); + } else { + width = track2(this.tree.getRoot()); + } + + return width; + }, + + _isVertical: function () { + var o = this.options; + return o.direction === BI.Direction.Top || o.direction === BI.Direction.Bottom; + }, + + _calculateHeight: function () { + var o = this.options; + var height = 0; + + function track1(node) { + var h = 0; + BI.each(node.getChildren(), function (i, child) { + h = Math.max(h, track1(child)); + }); + return h + (node.height || 0); + } + + function track2(node) { + var h = 0; + BI.each(node.getChildren(), function (i, child) { + h = Math.max(h, track2(child)); + }); + return h + (node.width || 0); + } + + if (this._isVertical()) { + height = track1(this.tree.getRoot()); + } else { + height = track2(this.tree.getRoot()); + } + return height; + }, + + _calculateXY: function (levels) { + var o = this.options; + var width = this._calculateWidth(); + var height = this._calculateHeight(); + var levelCount = levels.length; + var allLeavesCount = this._calculateLeaves(); + //计算坐标 + var xy = {}; + var levelHeight = height / levelCount; + BI.each(levels, function (i, nodes) { + //计算权重 + var weights = []; + BI.each(nodes, function (j, node) { + weights[j] = (node.get("leaves") || 1) / allLeavesCount; + }); + BI.each(nodes, function (j, node) { + //求前j个元素的权重 + var weight = BI.sum(weights.slice(0, j)); + //求坐标 + var x = weight * width + weights[j] * width / 2; + var y = i * levelHeight + levelHeight / 2; + xy[node.id] = {x: x, y: y}; + }) + }); + return xy; + }, + + _stroke: function (levels, xy) { + var height = this._calculateHeight(); + var levelCount = levels.length; + var levelHeight = height / levelCount; + var self = this, o = this.options; + switch (o.direction) { + case BI.Direction.Top: + BI.each(levels, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (node.getChildrenLength() > 0 && !node.leaf) { + var path = ""; + var start = xy[node.id]; + var split = start.y + levelHeight / 2; + path += "M" + start.x + "," + (start.y + o.centerOffset) + "L" + start.x + "," + split; + var end = []; + BI.each(node.getChildren(), function (t, c) { + var e = end[t] = xy[c.id]; + path += "M" + e.x + "," + (e.y + o.centerOffset) + "L" + e.x + "," + split; + }); + if (end.length > 0) { + path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split; + } + self.svg.path(path).attr("stroke", "#d4dadd"); + } + }) + }); + break; + case BI.Direction.Bottom: + BI.each(levels, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (node.getChildrenLength() > 0 && !node.leaf) { + var path = ""; + var start = xy[node.id]; + var split = start.y - levelHeight / 2; + path += "M" + start.x + "," + (start.y - o.centerOffset) + "L" + start.x + "," + split; + var end = []; + BI.each(node.getChildren(), function (t, c) { + var e = end[t] = xy[c.id]; + path += "M" + e.x + "," + (e.y - o.centerOffset) + "L" + e.x + "," + split; + }); + if (end.length > 0) { + path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split; + } + self.svg.path(path).attr("stroke", "#d4dadd"); + } + }) + }); + break; + case BI.Direction.Left: + BI.each(levels, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (node.getChildrenLength() > 0 && !node.leaf) { + var path = ""; + var start = xy[node.id]; + var split = start.y + levelHeight / 2; + path += "M" + (start.y + o.centerOffset) + "," + start.x + "L" + split + "," + start.x; + var end = []; + BI.each(node.getChildren(), function (t, c) { + var e = end[t] = xy[c.id]; + path += "M" + (e.y + o.centerOffset) + "," + e.x + "L" + split + "," + e.x; + }); + if (end.length > 0) { + path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x; + } + self.svg.path(path).attr("stroke", "#d4dadd"); + } + }) + }); + break; + case BI.Direction.Right: + BI.each(levels, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (node.getChildrenLength() > 0 && !node.leaf) { + var path = ""; + var start = xy[node.id]; + var split = start.y - levelHeight / 2; + path += "M" + (start.y - o.centerOffset) + "," + start.x + "L" + split + "," + start.x; + var end = []; + BI.each(node.getChildren(), function (t, c) { + var e = end[t] = xy[c.id]; + path += "M" + (e.y - o.centerOffset) + "," + e.x + "L" + split + "," + e.x; + }); + if (end.length > 0) { + path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x; + } + self.svg.path(path).attr("stroke", "#d4dadd"); + } + }) + }); + break; + } + }, + + _createBranches: function (levels) { + var self = this, o = this.options; + if (o.direction === BI.Direction.Bottom || o.direction === BI.Direction.Right) { + levels = levels.reverse(); + } + var xy = this._calculateXY(levels); + //画图 + this._stroke(levels, xy); + }, + + _isNeedAdjust: function () { + var o = this.options; + return o.direction === BI.Direction.Top && o.align === BI.VerticalAlign.Bottom || o.direction === BI.Direction.Bottom && o.align === BI.VerticalAlign.Top + || o.direction === BI.Direction.Left && o.align === BI.HorizontalAlign.Right || o.direction === BI.Direction.Right && o.align === BI.HorizontalAlign.Left + }, + + setValue: function (value) { + + }, + + getValue: function () { + + }, + + _transformToTreeFormat: 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++) { + 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(sNodes[i]); + } else { + r.push(sNodes[i]); + } + } + return r; + } else { + return [sNodes]; + } + }, + + populate: function (items) { + var self = this, o = this.options; + o.items = items || []; + this.empty(); + items = this._transformToTreeFormat(o.items); + this.tree = new BI.Tree(); + this.tree.initTree(items); + + this.svg = BI.createWidget({ + type: "bi.svg" + }); + + //树分层 + var levels = this._stratification(); + + if (this._isNeedAdjust()) { + //树平移 + var adjust = this._translate(levels); + //树调整 + adjust = this._adjust(adjust); + + this._createBranches(adjust); + } else { + var adjust = this._fill(levels); + + this._createBranches(adjust); + } + + var container = BI.createWidget({ + type: "bi.layout", + width: this._isVertical() ? this._calculateWidth() : this._calculateHeight(), + height: this._isVertical() ? this._calculateHeight() : this._calculateWidth() + }); + BI.createWidget({ + type: "bi.absolute", + element: container, + items: [{ + el: this.svg, + top: 0, + left: 0, + right: 0, + bottom: 0 + }] + }); + if (this._isVertical()) { + items = [{ + type: "bi.handstand_branch_tree", + expander: { + direction: o.direction + }, + el: { + layouts: [{ + type: "bi.horizontal_adapt", + verticalAlign: o.align + }] + }, + items: items + }] + } else { + items = [{ + type: "bi.branch_tree", + expander: { + direction: o.direction + }, + el: { + layouts: [{ + type: "bi.vertical" + }, { + type: o.align === BI.HorizontalAlign.Left ? "bi.left" : "bi.right" + }] + }, + items: items + }] + } + BI.createWidget({ + type: "bi.adaptive", + element: container, + items: items + }); + BI.createWidget({ + type: "bi.center_adapt", + scrollable: true, + element: this, + items: [container] + }); + } +}); +BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE"; +BI.shortcut("bi.branch_relation", BI.BranchRelation);/** + * 日期控件中的月份下拉框 + * + * Created by GUY on 2015/9/7. + * @class BI.MonthDateCombo + * @extends BI.Trigger + */ +BI.MonthDateCombo = BI.inherit(BI.Trigger, { + _defaultConfig: function() { + return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-combo", + height: 25 + }); + }, + _init: function() { + BI.MonthDateCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_triangle_trigger" + }); + + this.popup = BI.createWidget({ + type: "bi.month_popup" + }); + + this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ + self.setValue(self.popup.getValue()); + }) + + + this.combo = BI.createWidget({ + type: "bi.combo", + offsetStyle: "center", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: this.popup + } + }) + this.combo.on(BI.Combo.EVENT_CHANGE, function(){ + self.combo.hideView(); + self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE); + }); + }, + + setValue: function(v){ + this.trigger.setValue(v + 1); + this.popup.setValue(v); + }, + + getValue: function(){ + return this.popup.getValue(); + } +}); +BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.month_date_combo', BI.MonthDateCombo);/** + * 年份下拉框 + * + * Created by GUY on 2015/9/7. + * @class BI.YearDateCombo + * @extends BI.Trigger + */ +BI.YearDateCombo = BI.inherit(BI.Trigger, { + _defaultConfig: function() { + return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-combo", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function() { + BI.YearDateCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_triangle_trigger" + }); + + this.popup = BI.createWidget({ + type: "bi.year_popup", + min: o.min, + max: o.max + }); + + this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); + }) + + + this.combo = BI.createWidget({ + type: "bi.combo", + offsetStyle: "center", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: this.popup + } + }) + this.combo.on(BI.Combo.EVENT_CHANGE, function(){ + self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); + }) + }, + + setValue: function(v){ + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function(){ + return this.popup.getValue(); + } +}); +BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.year_date_combo', BI.YearDateCombo);/** + * Created by GUY on 2015/9/7. + * @class BI.DatePicker + * @extends BI.Widget + */ +BI.DatePicker = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-picker bi-background", + height: 25, + min: '1900-01-01', //最小日期 + max: '2099-12-31' //最大日期 + }) + }, + + _init: function () { + BI.DatePicker.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this._year = new Date().getFullYear(); + this._month = new Date().getMonth(); + this.left = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 25, + height: 25 + }); + this.left.on(BI.IconButton.EVENT_CHANGE, function () { + if (self._month === 0) { + self.setValue({ + year: self.year.getValue() - 1, + month: 11 + }) + } else { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() - 1 + }) + } + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }); + + this.right = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 25, + height: 25 + }); + + this.right.on(BI.IconButton.EVENT_CHANGE, function () { + if (self._month === 11) { + self.setValue({ + year: self.year.getValue() + 1, + month: 0 + }) + } else { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + 1 + }) + } + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }); + + this.year = BI.createWidget({ + type: "bi.year_date_combo", + min: o.min, + max: o.max + }); + this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + }); + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }) + this.month = BI.createWidget({ + type: "bi.month_date_combo" + }); + this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + }); + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.left, + width: 25 + }, { + type: "bi.center_adapt", + items: [{ + type: "bi.horizontal", + width: 100, + items: [this.year, this.month] + }] + }, { + el: this.right, + width: 25 + }] + }) + this.setValue({ + year: this._year, + month: this._month + }) + }, + + setValue: function (ob) { + this._year = ob.year; + this._month = ob.month; + this.year.setValue(ob.year); + this.month.setValue(ob.month); + }, + + getValue: function () { + return { + year: this.year.getValue(), + month: this.month.getValue() + } + } +}); +BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE" +BI.shortcut("bi.date_picker", BI.DatePicker);/** + * Created by GUY on 2015/9/7. + * @class BI.DateCalendarPopup + * @extends BI.Widget + */ +BI.DateCalendarPopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-calendar-popup", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + selectedTime: null + }) + }, + + _createNav: function (v) { + var date = BI.Calendar.getDateJSONByPage(v); + var calendar = BI.createWidget({ + type: "bi.calendar", + logic: { + dynamic: true + }, + min: this.options.min, + max: this.options.max, + year: date.year, + month: date.month, + day: this.selectedTime.day + }); + return calendar; + }, + + _init: function () { + BI.DateCalendarPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.today = new Date(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth(); + this._day = this.today.getDate(); + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month, + day: this._day + }; + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + min: o.min, + max: o.max + }); + + this.calendar = BI.createWidget({ + direction: "top", + element: this, + logic: { + dynamic: true + }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this), + + afterCardCreated: function () { + + }, + + afterCardShow: function () { + this.setValue(self.selectedTime); + } + }); + + this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { + self.selectedTime = self.datePicker.getValue(); + self.selectedTime.day = 1; + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + }); + + this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedTime = self.calendar.getValue(); + self.setValue(self.selectedTime); + self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + }, + + setValue: function (timeOb) { + this.datePicker.setValue(timeOb); + this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb)); + this.calendar.setValue(timeOb); + this.selectedTime = timeOb; + }, + + getValue: function () { + return this.selectedTime; + } +}); +BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/** + * 日期控件中的年份或月份trigger + * + * Created by GUY on 2015/9/7. + * @class BI.DateTriangleTrigger + * @extends BI.Trigger + */ +BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { + _const: { + height: 25, + iconWidth: 16, + iconHeight: 13 + }, + + _defaultConfig: function() { + return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", + height: 25 + }); + }, + _init: function() { + BI.DateTriangleTrigger.superclass._init.apply(this, arguments); + var o = this.options, c = this._const; + this.text = BI.createWidget({ + type: "bi.label", + cls: "list-item-text", + textAlign: "right", + text: o.text, + value: o.value, + height: c.height + }) + this.icon = BI.createWidget({ + type: "bi.icon", + width: c.iconWidth, + height: c.iconHeight + }); + + BI.createWidget({ + type: "bi.center_adapt", + element: this, + items: [{ + type: "bi.center_adapt", + width: 50, + height: c.height, + items: [this.text, this.icon] + }] + }) + }, + + setValue: function(v){ + this.text.setValue(v); + }, + + getValue: function(){ + return this.text.getValue(); + }, + + setText: function(v){ + this.text.setText(v); + }, + + getText: function(){ + return this.item.getText(); + }, + + getKey: function(){ + + } +}); +BI.shortcut('bi.date_triangle_trigger', BI.DateTriangleTrigger);/** + * 日期下拉框 + * + * Created by GUY on 2015/9/7. + * @class BI.DateCombo + * @extends BI.Widget + */ +BI.DateCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-combo bi-border", + height: 30 + }); + }, + _init: function () { + BI.DateCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_trigger" + }); + + this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + + this.popup = BI.createWidget({ + type: "bi.date_calendar_popup" + }); + + this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + width: 270, + el: this.popup, + stopPropagation: false + } + }) + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 30, + yearLength: 4, + yearMonthLength: 7 + }, + + _defaultConfig: function () { + return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-date-trigger", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.DateTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + var date = v.match(/\d+/g); + self._autoAppend(v, date); + return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({ + year: date[0], + month: date[1], + day: date[2] + }); + }, + quitChecker: function () { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + errorText: function () { + if (self.editor.isEditing()) { + return BI.i18nText("BI-Date_Trigger_Error_Text"); + } + return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + } + }); + this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN) + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.DateTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DateTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_VALID, function () { + self.fireEvent(BI.DateTrigger.EVENT_VALID); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DateTrigger.EVENT_ERROR); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setState(value); + } + + if (BI.isNotEmptyString(value)) { + var date = value.split("-"); + self.store_value = { + type: BI.DateTrigger.MULTI_DATE_CALENDAR, + value:{ + year: date[0] | 0, + month: date[1] - 1, + day: date[2] | 0 + } + }; + } + self.fireEvent(BI.DateTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.DateTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTrigger.EVENT_CHANGE); + }); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: BI.createWidget(), + width: 30 + }, { + el: this.editor + }] + }) + }, + _dateCheck: function (date) { + return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; + }, + _checkVoid: function (obj) { + return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; + }, + _autoAppend: function (v, dateObj) { + var self = this; + var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); + var yearCheck = function (v) { + return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max; + }; + var monthCheck = function (v) { + return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max; + }; + if (BI.isNotNull(dateObj) && Date.checkLegal(v)) { + switch (v.length) { + case this._const.yearLength: + if (yearCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + case this._const.yearMonthLength: + if (monthCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + } + } + }, + + setValue: function (v) { + var type, value, self = this; + var date = new Date(); + this.store_value = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value; + if(BI.isNull(value)){ + value = v; + } + } + var _setInnerValue = function (date, text) { + var dateStr = date.print("%Y-%x-%e"); + self.editor.setState(dateStr); + self.editor.setValue(dateStr); + self.setTitle(text + ":" + dateStr); + }; + switch (type) { + case BI.DateTrigger.MULTI_DATE_YEAR_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV]; + date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER]; + date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN]; + date = new Date(date.getFullYear(), 0, 1); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END]; + date = new Date(date.getFullYear(), 11, 31); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV]; + date = new Date().getBeforeMulQuarter(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER]; + date = new Date().getAfterMulQuarter(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN]; + date = new Date().getQuarterStartDate(); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END]; + date = new Date().getQuarterEndDate(); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV]; + date = new Date().getBeforeMultiMonth(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER]; + date = new Date().getAfterMultiMonth(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN]; + date = new Date(date.getFullYear(), date.getMonth(), 1); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END]; + date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_WEEK_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV]; + date = date.getOffsetDate(-7 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_WEEK_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER]; + date = date.getOffsetDate(7 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV]; + date = date.getOffsetDate(-1 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER]; + date = date.getOffsetDate(1 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_TODAY: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY]; + date = new Date(); + _setInnerValue(date, text); + break; + default: + if (BI.isNull(value) || BI.isNull(value.day)) { + this.editor.setState(""); + this.editor.setValue(""); + this.setTitle(""); + } else { + var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day; + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + this.setTitle(dateStr); + } + break; + } + }, + + getKey: function () { + return this.editor.getValue(); + }, + getValue: function () { + return this.store_value; + } + +}); + +BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1; +BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2; +BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3; +BI.DateTrigger.MULTI_DATE_YEAR_END = 4; + +BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5; +BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6; +BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7; +BI.DateTrigger.MULTI_DATE_MONTH_END = 8; + +BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9; +BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10; +BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11; +BI.DateTrigger.MULTI_DATE_QUARTER_END = 12; + +BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13; +BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14; + +BI.DateTrigger.MULTI_DATE_DAY_PREV = 15; +BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16; +BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17; + +BI.DateTrigger.MULTI_DATE_PARAM = 18; +BI.DateTrigger.MULTI_DATE_CALENDAR = 19; + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {}; +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today"); + +BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DateTrigger.EVENT_START = "EVENT_START"; +BI.DateTrigger.EVENT_STOP = "EVENT_STOP"; +BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DateTrigger.EVENT_VALID = "EVENT_VALID"; +BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.shortcut("bi.date_trigger", BI.DateTrigger);/** + * Created by zcf on 2017/2/20. + */ +BI.DatePaneWidget = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-pane-widget", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + selectedTime: null + }) + }, + _init: function () { + BI.DatePaneWidget.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.today = new Date(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth(); + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month + }; + + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + min: o.min, + max: o.max + }); + this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { + self.selectedTime = self.datePicker.getValue(); + // self.selectedTime.day = 1; + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + }); + + this.calendar = BI.createWidget({ + direction: "top", + element: this, + logic: { + dynamic: false + }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this) + + // afterCardCreated: function () { + // + // }, + // + // afterCardShow: function () { + // // this.setValue(self.selectedTime); + // } + }); + this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedTime = self.calendar.getValue(); + self.calendar.empty(); + self.setValue(self.selectedTime); + self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + + }, + + _createNav: function (v) { + var date = BI.Calendar.getDateJSONByPage(v); + var calendar = BI.createWidget({ + type: "bi.calendar", + logic: { + dynamic: false + }, + min: this.options.min, + max: this.options.max, + year: date.year, + month: date.month, + day: this.selectedTime.day + }); + return calendar; + }, + + _getNewCurrentDate: function () { + var today = new Date(); + return { + year: today.getFullYear(), + month: today.getMonth() + } + }, + + _setCalenderValue: function (date) { + this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date)); + this.calendar.setValue(date); + this.selectedTime = date; + }, + + _setDatePicker: function (timeOb) { + if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) { + this.datePicker.setValue(this._getNewCurrentDate()); + } else { + this.datePicker.setValue(timeOb); + } + }, + + _setCalendar: function (timeOb) { + if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) { + this.calendar.empty(); + this._setCalenderValue(this._getNewCurrentDate()); + } else { + this._setCalenderValue(timeOb) + } + }, + + setValue: function (timeOb) { + this._setDatePicker(timeOb); + this._setCalendar(timeOb); + }, + + getValue: function () { + return this.selectedTime; + } + +}); +BI.shortcut("bi.date_pane_widget", BI.DatePaneWidget);/** + * 带有方向的pathchooser + * + * Created by GUY on 2016/4/21. + * @class BI.DirectionPathChooser + * @extends BI.Widget + */ +BI.DirectionPathChooser = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#808080", + selectLineColor: "#009de3" + }, + + _defaultConfig: function () { + return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table", + items: [] + }); + }, + + _init: function () { + BI.DirectionPathChooser.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.pathChooser = BI.createWidget({ + type: "bi.path_chooser", + element: this, + items: o.items + }); + this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) { + //self._unselectAllArrows(); + self._setValue(start, index); + self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE); + }); + this._drawArrows(); + + }, + + _unselectAllArrows: function () { + var self = this, lineColor = this._const.lineColor; + BI.each(this.arrows, function (region, rs) { + BI.each(rs, function (idx, arrows) { + BI.each(arrows, function (i, arrow) { + arrow.attr({fill: lineColor, stroke: lineColor}); + }); + }); + }); + }, + + _drawOneArrow: function (dot, direction) { + //0,1,2,3 上右下左 + var lineColor = this._const.lineColor; + var selectLineColor = this._const.selectLineColor; + var svg = this.pathChooser.svg; + var path = ""; + switch (direction) { + case 0: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 3) + "," + (dot.y + 5) + + "L" + (dot.x + 3) + "," + (dot.y + 5) + + "L" + dot.x + "," + dot.y; + break; + case 1: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 5) + "," + (dot.y - 3) + + "L" + (dot.x - 5) + "," + (dot.y + 3) + + "L" + dot.x + "," + dot.y; + break; + case 2: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 3) + "," + (dot.y - 5) + + "L" + (dot.x + 3) + "," + (dot.y - 5) + + "L" + dot.x + "," + dot.y; + break; + case 3: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x + 5) + "," + (dot.y - 3) + + "L" + (dot.x + 5) + "," + (dot.y + 3) + + "L" + dot.x + "," + dot.y; + break; + } + return svg.path(path).attr({fill: lineColor, stroke: lineColor}); + }, + + _drawArrows: function () { + var self = this, o = this.options; + var routes = this.pathChooser.routes; + var pathes = this.pathChooser.pathes; + var store = this.pathChooser.store; + this.arrows = {}; + BI.each(routes, function (region, ps) { + self.arrows[region] = []; + BI.each(ps, function (idx, path) { + self.arrows[region][idx] = []; + var dots = pathes[region][idx]; + BI.each(dots, function (i, dot) { + if (i > 0 && i < dots.length - 1) { + var arrow; + if (dot.y === dots[i - 1].y) { + if (dots[i + 1].y != dot.y) { + if (store[path[path.length - 2]].direction === -1) { + if (i - 1 > 0) { + arrow = self._drawOneArrow(dots[i - 1], 3); + } + } else { + arrow = self._drawOneArrow(dots[i], 1); + } + } + } else if (dot.x === dots[i - 1].x) { + if (dot.y > dots[i - 1].y) { + if (store[BI.first(path)].direction === -1) { + arrow = self._drawOneArrow(dots[i - 1], 0); + } else { + arrow = self._drawOneArrow(dot, 2); + } + } else { + if (store[path[path.length - 2]].direction === -1) { + arrow = self._drawOneArrow(dots[i - 1], 2); + } else { + arrow = self._drawOneArrow(dot, 0); + } + } + } + if (arrow) { + self.arrows[region][idx].push(arrow); + } + } + }); + BI.each(path, function (i, node) { + if (i !== 0) { + var arrow; + var from = path[i - 1]; + if (store[from].direction === -1) { + var regionIndex = self.pathChooser.getRegionIndexById(from); + var x = getXoffsetByRegionIndex(regionIndex, -1); + var y = getYByXoffset(dots, x); + arrow = self._drawOneArrow({x: x, y: y}, 3); + } else { + var regionIndex = self.pathChooser.getRegionIndexById(node); + var x = getXoffsetByRegionIndex(regionIndex); + var y = getYByXoffset(dots, x); + arrow = self._drawOneArrow({x: x, y: y}, 1); + } + if (arrow) { + self.arrows[region][idx].push(arrow); + } + } + }); + }) + }); + + function getXoffsetByRegionIndex(regionIndex, diregion) { + if (diregion === -1) { + return 100 * (regionIndex + 1) - 20; + } + return 100 * regionIndex + 20; + } + + function getYByXoffset(dots, xoffset) { + var finded = BI.find(dots, function (i, dot) { + if (i > 0) { + if (dots[i - 1].x < xoffset && dots[i].x > xoffset) { + return true; + } + } + }); + return finded.y; + } + }, + + _setValue: function (start, index) { + var self = this; + var lineColor = this._const.lineColor; + var selectLineColor = this._const.selectLineColor; + var routes = this.pathChooser.routes; + var starts = this.pathChooser.start; + var each = [start]; + if (starts.contains(start)) { + each = starts; + } + BI.each(each, function (i, s) { + BI.each(self.arrows[s], function (j, arrows) { + BI.each(arrows, function (k, arrow) { + arrow.attr({fill: lineColor, stroke: lineColor}).toFront(); + }); + }); + }); + BI.each(this.arrows[start][index], function (i, arrow) { + arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); + }); + var current = BI.last(routes[start][index]); + while (current && routes[current] && routes[current].length === 1) { + BI.each(self.arrows[current][0], function (i, arrow) { + arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); + }); + current = BI.last(routes[current][0]); + } + }, + + setValue: function (v) { + this.pathChooser.setValue(v); + this._unselectAllArrows(); + var routes = this.pathChooser.routes; + var nodes = BI.keys(routes), self = this; + var result = [], array = []; + BI.each(v, function (i, val) { + if (BI.contains(nodes, val)) { + if (array.length > 0) { + array.push(val); + result.push(array); + array = []; + } + } + array.push(val); + }); + if (array.length > 0) { + result.push(array); + } + //画这n条路径 + BI.each(result, function (idx, path) { + var start = path[0]; + var index = BI.findIndex(routes[start], function (idx, p) { + if (BI.isEqual(path, p)) { + return true; + } + }); + if (index >= 0) { + self._setValue(start, index); + } + }); + }, + + getValue: function () { + return this.pathChooser.getValue(); + }, + + populate: function (items) { + this.pathChooser.populate(items); + this._drawArrows(); + } +}); +BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE"; +BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/** + * Created by roy on 15/8/14. + */ +BI.DownListCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-down-list-combo", + invalid: false, + height: 25, + items: [], + adjustLength: 0, + direction: "bottom", + trigger: "click", + el: {} + }) + }, + + _init: function () { + BI.DownListCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.popupview = BI.createWidget({ + type: "bi.down_list_popup", + items: o.items, + chooseType: o.chooseType + }); + + this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) { + self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); + self.downlistcombo.hideView(); + }); + + this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { + self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); + self.downlistcombo.hideView(); + }); + + + this.downlistcombo = BI.createWidget({ + element: this, + type: 'bi.combo', + trigger: o.trigger, + isNeedAdjustWidth: false, + adjustLength: o.adjustLength, + direction: o.direction, + el: BI.createWidget(o.el, { + type: "bi.icon_trigger", + extraCls: o.iconCls ? o.iconCls : "pull-down-font", + width: o.width, + height: o.height + }), + popup: { + el: this.popupview, + stopPropagation: true, + maxHeight: 1000 + } + }); + + this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + hideView: function () { + this.downlistcombo.hideView(); + }, + + showView: function () { + this.downlistcombo.showView(); + }, + + populate: function (items) { + this.popupview.populate(items); + }, + + setValue: function (v) { + this.popupview.setValue(v); + }, + getValue: function () { + return this.popupview.getValue() + } +}); +BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; +BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; + +BI.shortcut("bi.down_list_combo", BI.DownListCombo);/** + * Created by roy on 15/9/6. + */ +BI.DownListGroup = BI.inherit(BI.Widget, { + constants: { + iconCls: "check-mark-ha-font" + }, + _defaultConfig: function () { + return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-down-list-group", + items: [ + { + el: {} + } + ] + }) + }, + _init: function () { + BI.DownListGroup.superclass._init.apply(this, arguments); + var o = this.options, self = this; + + this.downlistgroup = BI.createWidget({ + element: this, + type: "bi.button_tree", + items: o.items, + chooseType: 0,//0单选,1多选 + layouts: [{ + type: "bi.vertical", + hgap: 0, + vgap: 0 + }] + }); + this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if(type === BI.Events.CLICK) { + self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments); + } + }) + }, + getValue:function(){ + return this.downlistgroup.getValue(); + }, + setValue:function(v){ + this.downlistgroup.setValue(v); + } + + +}) +BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.Single, { + _defaultConfig: function () { + var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-down-list-item bi-list-item-active", + cls: "", + height: 25, + logic: { + dynamic: true + }, + selected: false, + iconHeight: null, + iconWidth: null, + textHgap: 0, + textVgap: 0, + textLgap: 0, + textRgap: 0 + }) + }, + _init: function () { + BI.DownListItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.text = BI.createWidget({ + type: "bi.icon_text_item", + element: this, + height: o.height, + text: o.text, + value: o.value, + logic: o.logic, + selected: o.selected, + disabled: o.disabled, + iconHeight: o.iconHeight, + iconWidth: o.iconWidth, + textHgap: o.textHgap, + textVgap: o.textVgap, + textLgap: o.textLgap, + textRgap: o.textRgap, + father: o.father + }); + this.text.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.text.on(BI.IconTextItem.EVENT_CHANGE, function () { + self.fireEvent(BI.DownListItem.EVENT_CHANGE); + }); + // this.setSelected(o.selected); + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + isSelected: function () { + return this.text.isSelected(); + }, + + setSelected: function (b) { + this.text.setSelected(b); + // if (b === true) { + // this.element.addClass("dot-e-font"); + // } else { + // this.element.removeClass("dot-e-font"); + // } + }, + + setValue: function (v) { + this.text.setValue(v); + }, + + getValue: function () { + return this.text.getValue(); + } +}); +BI.DownListItem.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-down-list-group-item", + logic: { + dynamic: false + }, + // invalid: true, + iconCls1: "dot-e-font", + iconCls2: "pull-right-e-font" + }) + }, + _init: function () { + BI.DownListGroupItem.superclass._init.apply(this, arguments); + var o = this.options; + var self = this; + this.text = BI.createWidget({ + type: "bi.label", + cls: "list-group-item-text", + textAlign: "left", + text: o.text, + value: o.value, + height: o.height + }); + + this.icon1 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls1, + width: 25, + forceNotSelected: true + }); + + this.icon2 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls2, + width: 25, + forceNotSelected: true + }); + + var blank = BI.createWidget({ + type: "bi.layout", + width: 25 + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.icon2, + top: 0, + bottom: 0, + right: 0 + }] + }); + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { + items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank) + })))); + + this.element.hover(function () { + if (self.isEnabled()) { + self.hover(); + } + }, function () { + if (self.isEnabled()) { + self.dishover() + } + }); + }, + + hover: function () { + BI.DownListGroupItem.superclass.hover.apply(this, arguments); + this.icon1.element.addClass("hover"); + this.icon2.element.addClass("hover"); + + }, + + dishover: function () { + BI.DownListGroupItem.superclass.dishover.apply(this, arguments); + this.icon1.element.removeClass("hover"); + this.icon2.element.removeClass("hover"); + }, + + doClick: function () { + BI.DownListGroupItem.superclass.doClick.apply(this, arguments); + if (this.isValid()) { + this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue()); + } + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + setValue: function (v) { + var self = this, o = this.options; + v = BI.isArray(v) ? v : [v]; + BI.find(v, function (idx, value) { + if (BI.contains(o.childValues, value)) { + self.icon1.setSelected(true); + return true; + } else { + self.icon1.setSelected(false); + } + }) + } +}); +BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/** + * Created by roy on 15/9/8. + * 处理popup中的item分组样式 + * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项 + */ +BI.DownListPopup = BI.inherit(BI.Pane, { + constants: { + nextIcon: "pull-right-e-font", + height: 25, + iconHeight: 12, + iconWidth: 12, + hgap: 0, + vgap: 0, + border: 1 + }, + _defaultConfig: function () { + var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-down-list-popup", + items: [], + chooseType: BI.Selection.Multi + }) + }, + _init: function () { + BI.DownListPopup.superclass._init.apply(this, arguments); + this.singleValues = []; + this.childValueMap = {}; + this.fatherValueMap = {}; + var self = this, o = this.options, children = this._createChildren(o.items); + this.popup = BI.createWidget({ + type: "bi.button_tree", + items: BI.createItems(children, + {}, { + adjustLength: -2 + } + ), + layouts: [{ + type: "bi.vertical", + hgap: this.constants.hgap, + vgap: this.constants.vgap + }], + chooseType: o.chooseType + }); + + this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) { + var changedValue = value; + if (BI.isNotNull(self.childValueMap[value])) { + changedValue = self.childValueMap[value]; + self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value]) + } else { + self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object); + } + + + if (!self.singleValues.contains(changedValue)) { + var item = self.getValue(); + var result = []; + BI.each(item, function (i, valueObject) { + if (valueObject.value != changedValue) { + result.push(valueObject); + } + }); + self.setValue(result); + } + + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.popup] + }); + + }, + _createChildren: function (items) { + var self = this, result = []; + BI.each(items, function (i, it) { + var item_done = { + type: "bi.down_list_group", + items: [] + }; + + BI.each(it, function (i, item) { + if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) { + item.type = "bi.combo_group"; + item.cls = "down-list-group"; + item.trigger = "hover"; + item.isNeedAdjustWidth = false; + item.el.title = item.el.title || item.el.text; + item.el.type = "bi.down_list_group_item"; + item.el.logic = { + dynamic: true + }; + item.el.height = self.constants.height; + item.el.iconCls2 = self.constants.nextIcon; + item.popup = { + lgap: 4, + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical" + }] + + } + }; + item.el.childValues = []; + BI.each(item.children, function (i, child) { + var fatherValue = BI.deepClone(item.el.value); + var childValue = BI.deepClone(child.value); + self.singleValues.push(child.value); + child.type = "bi.down_list_item"; + child.extraCls = " child-down-list-item"; + child.title = child.title || child.text; + child.textRgap = 10; + child.isNeedAdjustWidth = false; + child.logic = { + dynamic: true + }; + child.father = fatherValue; + self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; + self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; + child.value = self._createChildValue(fatherValue, childValue); + item.el.childValues.push(child.value); + }) + } else { + item.type = "bi.down_list_item"; + item.title = item.title || item.text; + item.textRgap = 10; + item.isNeedAdjustWidth = false; + item.logic = { + dynamic: true + } + } + var el_done = {}; + el_done.el = item; + item_done.items.push(el_done); + }); + if (self._isGroup(item_done.items)) { + BI.each(item_done.items, function (i, item) { + self.singleValues.push(item.el.value); + }) + } + + result.push(item_done); + if (self._needSpliter(i, items.length)) { + var spliter_container = BI.createWidget({ + type: "bi.vertical", + items: [{ + el: { + type: "bi.layout", + cls: "bi-down-list-spliter bi-border-top cursor-pointer", + height: 0 + } + + }], + cls: "bi-down-list-spliter-container cursor-pointer", + lgap: 10, + rgap: 10 + }); + result.push(spliter_container); + } + }); + return result; + }, + + _isGroup: function (i) { + return i.length > 1; + }, + + _needSpliter: function (i, itemLength) { + return i < itemLength - 1; + }, + + _createChildValue: function (fatherValue, childValue) { + return fatherValue + "_" + childValue + }, + + populate: function (items) { + BI.DownListPopup.superclass.populate.apply(this, arguments); + var self = this; + self.childValueMap = {}; + self.fatherValueMap = {}; + self.singleValues = []; + var children = self._createChildren(items); + var popupItem = BI.createItems(children, + {}, { + adjustLength: -2 + } + ); + self.popup.populate(popupItem); + }, + + setValue: function (valueItem) { + var self = this; + var valueArray = []; + BI.each(valueItem, function (i, item) { + var value; + if (BI.isNotNull(item.childValue)) { + value = self._createChildValue(item.value, item.childValue); + } else { + value = item.value; + } + valueArray.push(value); + } + ); + this.popup.setValue(valueArray); + }, + + getValue: function () { + var self = this, result = []; + var values = this.popup.getValue(); + BI.each(values, function (i, value) { + var valueItem = {}; + if (BI.isNotNull(self.childValueMap[value])) { + var fartherValue = self.fatherValueMap[value]; + valueItem.childValue = self.childValueMap[value]; + valueItem.value = fartherValue; + } else { + valueItem.value = value; + } + result.push(valueItem); + }); + return result; + } + + +}); + +BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; +BI.shortcut("bi.down_list_popup", BI.DownListPopup);/** + * + * Created by GUY on 2016/3/28. + * @class BI.ExcelTableCell + * @extends BI.Widget + */ +BI.ExcelTableCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ExcelTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table-cell", + text: "" + }); + }, + + _init: function () { + BI.ExcelTableCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.excel_table_cell', BI.ExcelTableCell);/** + * + * Created by GUY on 2016/3/28. + * @class BI.ExcelTableHeaderCell + * @extends BI.Widget + */ +BI.ExcelTableHeaderCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ExcelTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table-header-cell bi-background", + text: "" + }); + }, + + _init: function () { + BI.ExcelTableHeaderCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: BI.HorizontalAlign.Center, + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.excel_table_header_cell', BI.ExcelTableHeaderCell);/** + * Excel表格 + * + * Created by GUY on 2016/3/28. + * @class BI.ExcelTable + * @extends BI.Widget + */ +BI.ExcelTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table", + el: { + type: "bi.responsive_table" + }, + + isNeedResize: false, + isResizeAdapt: true, + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 + return BI.isEqual(row1, row2); + }, + + columnSize: [], + headerRowSize: 37, + footerRowSize: 37, + rowSize: 37, + + regionColumnSize: false, + + items: [] //二维数组 + }); + }, + + _init: function () { + BI.ExcelTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var mergeCols = []; + BI.each(o.mergeCols, function (i, col) { + mergeCols.push(col + 1); + }); + this.table = BI.createWidget(o.el, { + type: "bi.table_view", + element: this, + + isNeedFreeze: false, + + isNeedMerge: o.isNeedMerge, + mergeCols: mergeCols, + mergeRule: o.mergeRule, + + columnSize: [""].concat(o.columnSize), + headerRowSize: 18, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize || [82, ""] + }); + + if (BI.isNotEmptyArray(o.items)) { + this.populate(o.items); + } + BI.nextTick(function () { + self.setRegionColumnSize(o.regionColumnSize || [82, ""]); + }); + }, + + resize: function () { + this.table.resize(); + }, + + setColumnSize: function (columnSize) { + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + this.table.setHeaderColumnSize(columnSize); + }, + + setRegionColumnSize: function (columnSize) { + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize(); + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize(); + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + resizeHeader: function () { + this.table.resize(); + this.table._resizeHeader && this.table._resizeHeader(); + }, + + attr: function (key,value) { + var self = this; + if (BI.isObject(key)) { + BI.each(key, function (k, v) { + self.attr(k, v); + }); + return; + } + BI.ExcelTable.superclass.attr.apply(this, arguments); + switch (key){ + case "mergeCols": + var mCols = []; + BI.each(value, function (i, col) { + mCols.push(col + 1); + }); + value=mCols; + break; + } + this.table.attr.apply(this.table, arguments); + }, + + populate: function (rows) { + var self = this; + var columnSize = this.getColumnSize(); + var items = []; + var header = [{ + type: "bi.excel_table_header_cell" + }]; + if (BI.isNotNull(rows)) { + BI.each(columnSize, function (i, size) { + header.push({ + type: "bi.excel_table_header_cell", + text: BI.int2Abc(i + 1) + }); + }); + BI.each(rows, function (i, row) { + items.push([{ + type: "bi.excel_table_header_cell", + text: (i + 1) + }].concat(row)); + }); + } + this.table.populate(items, [header]); + }, + + destroy: function () { + this.table.destroy(); + BI.ExcelTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.excel_table', BI.ExcelTable);/** + * 文件管理控件组 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerButtonGroup + * @extends BI.Widget + */ +BI.FileManagerButtonGroup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-button_group", + items: [] + }) + }, + + _init: function () { + BI.FileManagerButtonGroup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.button_group = BI.createWidget({ + type: "bi.button_tree", + element: this, + chooseType: BI.Selection.Multi, + items: this._formatItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + _formatItems: function (items) { + var self = this, o = this.options; + BI.each(items, function (i, item) { + if (item.children && item.children.length > 0) { + item.type = "bi.file_manager_folder_item"; + } else { + item.type = "bi.file_manager_file_item"; + } + }); + return items; + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getNotSelectedValue: function () { + return this.button_group.getNotSelectedValue(); + }, + + getAllLeaves: function () { + return this.button_group.getAllLeaves(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + getSelectedButtons: function () { + return this.button_group.getSelectedButtons(); + }, + + getNotSelectedButtons: function () { + return this.button_group.getNotSelectedButtons(); + }, + + populate: function (items) { + this.button_group.populate(this._formatItems(items)); + } +}); +BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManager + * @extends BI.Widget + */ +BI.FileManager = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager", + el: {}, + items: [] + }) + }, + + _init: function () { + BI.FileManager.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + var items = BI.Tree.transformToTreeFormat(o.items); + this.tree.initTree(items); + this.selectedValues = []; + this.nav = BI.createWidget({ + type: "bi.file_manager_nav", + items: BI.deepClone(items) + }); + this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) { + if (value == "-1") {//根节点 + self.populate({children: self.tree.toJSON()}); + } else { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } + self.setValue(self.selectedValues); + }); + this.list = BI.createWidget(o.el, { + type: "bi.file_manager_list", + items: items + }); + this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) { + if (type === BI.Events.CHANGE) { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } else if (type === BI.Events.CLICK) { + var values = []; + if (obj instanceof BI.MultiSelectBar) { + var t = self.list.getValue(); + selected = t.type === BI.Selection.All; + values = BI.concat(t.assist, t.value); + } else { + values = obj.getAllLeaves(); + } + BI.each(values, function (i, v) { + if (selected === true) { + self.selectedValues.pushDistinct(v); + } else { + self.selectedValues.remove(v); + } + }); + } + self.setValue(self.selectedValues); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.list, + left: 0, + right: 0, + top: 0, + bottom: 10 + }, { + el: this.nav, + left: 40, + right: 100, + top: 0 + }] + }); + }, + + setValue: function (value) { + this.selectedValues = value || []; + this.list.setValue(this.selectedValues); + }, + + getValue: function () { + var obj = this.list.getValue(); + var res = obj.type === BI.Selection.All ? obj.assist : obj.value; + res.pushDistinctArray(this.selectedValues); + return res; + }, + + _populate: function (items) { + this.list.populate(items); + }, + + getSelectedValue: function () { + return this.nav.getValue()[0]; + }, + + getSelectedId: function () { + return this.nav.getId()[0]; + }, + + populate: function (node) { + var clone = BI.deepClone(node); + this._populate(node.children); + this.nav.populate(clone); + } +}); +BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE"; +BI.shortcut("bi.file_manager", BI.FileManager);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFileItem + * @extends BI.Single + */ +BI.FileManagerFileItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom", + height: 30 + }) + }, + + _init: function () { + BI.FileManagerFileItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-file-font" + }, + width: 20 + }, { + el: { + type: "bi.label", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + } + }] + }) + }, + + getAllLeaves: function(){ + return [this.options.value]; + }, + + isSelected: function () { + return this.checked.isSelected(); + }, + + setSelected: function (v) { + this.checked.setSelected(v); + } +}); +BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFolderItem + * @extends BI.Single + */ +BI.FileManagerFolderItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom", + height: 30 + }) + }, + + _init: function () { + BI.FileManagerFolderItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button = BI.createWidget({ + type: "bi.text_button", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self); + }); + + this.tree = new BI.Tree(); + this.tree.initTree([{ + id: o.id, + children: o.children + }]); + this.selectValue = []; + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-folder-font" + }, + width: 20 + }, { + el: this.button + }] + }) + }, + + setAllSelected: function (v) { + this.checked.setSelected(v); + this.selectValue = []; + }, + + setHalfSelected: function (v) { + this.checked.setHalfSelected(v); + if(!v){ + this.selectValue = []; + } + }, + + setValue: function (v) { + var self = this, o = this.options; + var isHalf = false; + var selectValue = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + if (BI.contains(v, node.get("data").value)) { + selectValue.push(node.get("data").value); + } else { + isHalf = true; + } + } + }); + this.setAllSelected(selectValue.length > 0 && !isHalf); + this.setHalfSelected(selectValue.length > 0 && isHalf); + if (this.checked.isHalfSelected()) { + this.selectValue = selectValue; + } + }, + + getAllButtons: function () { + return [this]; + }, + + getAllLeaves: function () { + var o = this.options; + var res = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value) + } + }); + return res; + }, + + getNotSelectedValue: function () { + var self = this, o = this.options; + var res = []; + var isAllSelected = this.checked.isSelected(); + if (isAllSelected === true) { + return res; + } + var isHalfSelected = this.checked.isHalfSelected(); + this.tree.traverse(function (node) { + if (node.isLeaf()) { + var v = node.get("data").value; + if (isHalfSelected === true) { + if (!BI.contains(self.selectValue, node.get("data").value)) { + res.push(v); + } + } else { + res.push(v); + } + } + }); + return res; + }, + + getValue: function () { + var res = []; + if (this.checked.isSelected()) { + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value); + } + }); + return res; + } + if (this.checked.isHalfSelected()) { + return this.selectValue; + } + return []; + } +}); +BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/** + * 文件管理控件列表 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerList + * @extends BI.Widget + */ +BI.FileManagerList = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-list", + el: {}, + items: [] + }) + }, + + _init: function () { + BI.FileManagerList.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.list = BI.createWidget({ + type: "bi.select_list", + element: this, + items: o.items, + toolbar: { + type: "bi.multi_select_bar", + height: 40, + text: "" + }, + el: { + type: "bi.list_pane", + el: BI.isWidget(o.el) ? o.el : BI.extend({ + type: "bi.file_manager_button_group" + }, o.el) + } + }); + this.list.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + setValue: function (v) { + this.list.setValue({ + value: v + }); + }, + + getValue: function () { + return this.list.getValue(); + }, + + populate: function (items) { + this.list.populate(items); + this.list.setToolBarVisible(true); + } +}); +BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_list", BI.FileManagerList);/** + * 文件管理导航按钮 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNavButton + * @extends BI.Widget + */ +BI.FileManagerNavButton = BI.inherit(BI.Widget, { + + _const: { + normal_color: "#ffffff", + select_color: "#f4f4f4" + }, + _defaultConfig: function () { + return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav-button", + selected: false, + height: 40 + }) + }, + + _init: function () { + BI.FileManagerNavButton.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.button = BI.createWidget({ + type: "bi.text_button", + cls: "file-manager-nav-button-text bi-card", + once: true, + selected: o.selected, + text: o.text, + title: o.text, + value: o.value, + height: o.height, + lgap: 20, + rgap: 10 + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + var svg = BI.createWidget({ + type: "bi.svg", + cls: "file-manager-nav-button-triangle", + width: 15, + height: o.height + }); + var path = svg.path("M0,0L15,20L0,40").attr({ + "stroke": c.select_color, + "fill": o.selected ? c.select_color : c.normal_color + }); + this.button.on(BI.TextButton.EVENT_CHANGE, function () { + if (this.isSelected()) { + path.attr("fill", c.select_color); + } else { + path.attr("fill", c.normal_color); + } + }); + BI.createWidget({ + type: "bi.default", + element: this, + items: [this.button] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: svg, + right: -15, + top: 0, + bottom: 0 + }] + }) + }, + + isSelected: function () { + return this.button.isSelected(); + }, + + setValue: function (v) { + this.button.setValue(v); + }, + + getValue: function () { + return this.button.getValue(); + }, + + populate: function (items) { + + } +}); +BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/** + * 文件管理导航 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNav + * @extends BI.Widget + */ +BI.FileManagerNav = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav bi-border-left", + height: 40, + items: [] + }) + }, + + _init: function () { + BI.FileManagerNav.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + this.refreshTreeData(o.items); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + this.button_group = BI.createWidget({ + type: "bi.button_group", + element: this, + items: [{ + type: "bi.file_manager_nav_button", + text: BI.i18nText("BI-Created_By_Me"), + selected: true, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME, + value: BI.FileManagerNav.ROOT_CREATE_BY_ME + }], + layouts: [{ + type: "bi.horizontal" + }] + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) { + self.fireEvent(BI.FileManagerNav.EVENT_CHANGE, arguments); + }); + }, + + _getAllParents: function (id) { + var node, res = []; + if (!id) { + node = this.tree.getRoot(); + } else { + node = this.tree.search(id); + } + while (node.parent) { + res.push(node); + node = node.parent; + } + res.push(node); + return res.reverse(); + }, + + _formatNodes: function (nodes) { + var res = []; + BI.each(nodes, function (i, node) { + res.push(BI.extend({ + type: "bi.file_manager_nav_button", + id: node.id + }, node.get("data"))); + }); + BI.last(res).selected = true; + return res; + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getId: function () { + var ids = []; + BI.each(this.button_group.getSelectedButtons(), function (i, btn) { + ids.push(btn.attr("id")); + }); + return ids; + }, + + refreshTreeData: function(items){ + this.tree.initTree(BI.Tree.transformToTreeFormat(items)); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + }, + + populate: function (node) { + var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id); + this.button_group.populate(this._formatNodes(parents)); + } +}); +BI.extend(BI.FileManagerNav, { + ROOT_CREATE_BY_ME: "-1" +}); +BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** + * Created by windy on 2017/3/13. + * 数值微调器 + */ +BI.FineTuningNumberEditor = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-fine-tuning-number-editor bi-border", + value: -1 + }) + }, + + _init: function () { + BI.FineTuningNumberEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + value: this._alertInEditorValue(o.value), + errorText: BI.i18nText("BI-Please_Input_Natural_Number"), + validationChecker: function(v){ + return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1; + } + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){ + self._finetuning(0); + self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(1); + self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); + }); + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(-1); + self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); + }); + this._finetuning(0); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [this.editor, { + el: { + type: "bi.grid", + columns: 1, + rows: 2, + items: [{ + column: 0, + row: 0, + el: this.topBtn + }, { + column: 0, + row: 1, + el: this.bottomBtn + }] + }, + width: 30 + }] + }); + }, + + _alertOutEditorValue: function(v){ + return v === BI.i18nText("BI-Basic_Auto") ? -1 : v; + }, + + _alertInEditorValue: function(v){ + return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v; + }, + + //微调 + _finetuning: function(add){ + var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); + this.editor.setValue(this._alertInEditorValue(v + add)); + this.bottomBtn.setEnable((v + add) > -1); + }, + + getValue: function () { + var v = this.editor.getValue(); + return this._alertOutEditorValue(v); + }, + + setValue: function (v) { + this.editor.setValue(this._alertInEditorValue(v)); + this._finetuning(0); + } + +}); +BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/** + * 交互行为布局 + * + * + * Created by GUY on 2016/7/23. + * @class BI.InteractiveArrangement + * @extends BI.Widget + */ +BI.InteractiveArrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-interactive-arrangement", + resizable: true, + layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, + items: [] + }); + }, + + _init: function () { + BI.InteractiveArrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.adaptive_arrangement", + element: this, + resizable: o.resizable, + layoutType: o.layoutType, + items: o.items + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () { + self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments); + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () { + self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments); + }); + + this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) { + var p = self._getRegionClientPosition(id); + self.draw({ + left: p.left, + top: p.top + }, size, id); + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) { + self.stopDraw(); + self.setRegionSize(id, size); + }); + + this.tags = []; + + }, + + _isEqual: function (num1, num2) { + return this.arrangement._isEqual(num1, num2); + }, + + _getScrollOffset: function () { + return this.arrangement._getScrollOffset(); + }, + + _positionAt: function (position, regions) { + var self = this; + regions = regions || this.getAllRegions(); + var left = [], center = [], right = [], top = [], middle = [], bottom = []; + BI.each(regions, function (i, region) { + var client = self._getRegionClientPosition(region.id); + if (Math.abs(client.left - position.left) <= 3) { + left.push(region); + } + if (Math.abs(client.left + client.width / 2 - position.left) <= 3) { + center.push(region); + } + if (Math.abs(client.left + client.width - position.left) <= 3) { + right.push(region); + } + if (Math.abs(client.top - position.top) <= 3) { + top.push(region); + } + if (Math.abs(client.top + client.height / 2 - position.top) <= 3) { + middle.push(region); + } + if (Math.abs(client.top + client.height - position.top) <= 3) { + bottom.push(region); + } + }); + return { + left: left, + center: center, + right: right, + top: top, + middle: middle, + bottom: bottom + } + }, + + _getRegionClientPosition: function (name) { + var region = this.getRegionByName(name); + var offset = this.arrangement._getScrollOffset(); + return { + top: region.top - offset.top, + left: region.left - offset.left, + width: region.width, + height: region.height, + id: region.id + } + }, + + _vAlign: function (position, regions) { + var self = this; + var vs = this._positionAt(position, regions); + var positions = []; + var l; + if (vs.left.length > 0) { + l = this._getRegionClientPosition(vs.left[0].id).left; + } else if (vs.right.length > 0) { + var temp = this._getRegionClientPosition(vs.right[0].id); + l = temp.left + temp.width; + } + var rs = vs.left.concat(vs.right); + BI.each(rs, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l)) { + var topPoint = { + top: p.top + p.height / 2, + left: l + }; + positions.push({ + id: region.id, + start: topPoint, + end: { + left: l, + top: position.top + } + }); + } + }); + return positions; + }, + + _leftAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left, + top: position.top + size.height / 2 + }, regions); + }, + + _rightAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left + size.width, + top: position.top + size.height / 2 + }, regions); + }, + + _hAlign: function (position, regions) { + var self = this; + var hs = this._positionAt(position, regions); + var positions = []; + var t; + if (hs.top.length > 0) { + var temp = this._getRegionClientPosition(hs.top[0].id); + t = temp.top; + } else if (hs.bottom.length > 0) { + var temp = this._getRegionClientPosition(hs.bottom[0].id); + t = temp.top + temp.height; + } + var rs = hs.top.concat(hs.bottom); + BI.each(rs, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t)) { + var leftPoint = { + top: t, + left: p.left + p.width / 2 + }; + positions.push({ + id: p.id, + start: leftPoint, + end: { + left: position.left, + top: t + } + }); + } + }); + return positions; + }, + + _topAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + }, regions); + }, + + _bottomAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + size.height + }, regions); + }, + + _centerAlign: function (position, size, regions) { + var self = this; + var cs = this._positionAt({ + left: position.left + size.width / 2, + top: position.top + size.height / 2 + }, regions); + var positions = []; + var l; + if (cs.center.length > 0) { + var temp = this._getRegionClientPosition(cs.center[0].id); + l = temp.left + temp.width / 2; + } + BI.each(cs.center, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.left + p.width / 2, l)) { + var topPoint = { + top: p.top + p.height / 2, + left: p.left + p.width / 2 + }; + positions.push({ + id: p.id, + start: topPoint, + end: { + left: l, + top: position.top + size.height / 2 + } + }); + } + }); + return positions; + }, + + _middleAlign: function (position, size, regions) { + var self = this; + var cs = this._positionAt({ + left: position.left + size.width / 2, + top: position.top + size.height / 2 + }, regions); + var positions = []; + var t; + if (cs.middle.length > 0) { + var temp = this._getRegionClientPosition(cs.middle[0].id); + t = temp.top + temp.height / 2; + } + BI.each(cs.middle, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.top + p.height / 2, t)) { + var topPoint = { + top: p.top + p.height / 2, + left: p.left + p.width / 2 + }; + positions.push({ + id: p.id, + start: topPoint, + end: { + left: position.left + size.width / 2, + top: t + } + }); + } + }); + return positions; + }, + + + _drawOneTag: function (start, end) { + var s = BI.createWidget({ + type: "bi.icon_button", + //invisible: true, + width: 13, + height: 13, + cls: "drag-tag-font interactive-arrangement-dragtag-icon" + }); + var e = BI.createWidget({ + type: "bi.icon_button", + //invisible: true, + width: 13, + height: 13, + cls: "drag-tag-font interactive-arrangement-dragtag-icon" + }); + if (this._isEqual(start.left, end.left)) { + var line = BI.createWidget({ + type: "bi.layout", + //invisible: true, + cls: "interactive-arrangement-dragtag-line", + width: 1, + height: Math.abs(start.top - end.top) + }); + } else { + var line = BI.createWidget({ + type: "bi.layout", + //invisible: true, + cls: "interactive-arrangement-dragtag-line", + height: 1, + width: Math.abs(start.left - end.left) + }); + } + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: s, + left: start.left - 6, + top: start.top - 7 + }, { + el: e, + left: end.left - 6, + top: end.top - 7 + }, { + el: line, + left: Math.min(start.left, end.left), + top: Math.min(start.top, end.top) + }] + }); + this.tags.push(s); + this.tags.push(e); + this.tags.push(line); + }, + + stopDraw: function () { + BI.each(this.tags, function (i, w) { + w.destroy(); + }); + this.tags = []; + }, + + _getRegionExcept: function (name, regions) { + var other = []; + BI.each(regions || this.getAllRegions(), function (i, region) { + if (!(name && region.id === name)) { + other.push(region); + } + }); + return other; + }, + + getClientWidth: function () { + return this.arrangement.getClientWidth(); + }, + + getClientHeight: function () { + return this.arrangement.getClientHeight(); + }, + + getPosition: function (name, position, size) { + var regions = this.getAllRegions(); + var me; + if (name) { + me = this._getRegionClientPosition(name); + } + var other = this._getRegionExcept(name, regions); + position = position || { + left: me.left, + top: me.top + }; + size = size || { + width: me.width, + height: me.height + }; + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + position.left = pos.end.left - size.width / 2; + }); + BI.each(right, function (i, pos) { + position.left = pos.end.left - size.width; + }); + BI.each(left, function (i, pos) { + position.left = pos.end.left; + }); + BI.each(middle, function (i, pos) { + position.top = pos.end.top - size.height / 2; + }); + BI.each(bottom, function (i, pos) { + position.top = pos.end.top - size.height; + }); + BI.each(top, function (i, pos) { + position.top = pos.end.top; + }); + return position; + }, + + //position不动 变size + getSize: function (name, position, size) { + var regions = this.getAllRegions(); + var me; + if (name) { + me = this._getRegionClientPosition(name); + } + var other = this._getRegionExcept(name, regions); + position = position || { + left: me.left, + top: me.top + }; + size = size || { + width: me.width, + height: me.height + }; + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + size.width = (pos.end.left - position.left) * 2; + }); + BI.each(right, function (i, pos) { + size.width = pos.end.left - position.left; + }); + BI.each(left, function (i, pos) { + }); + BI.each(middle, function (i, pos) { + size.height = (pos.end.top - position.top) * 2; + }); + BI.each(bottom, function (i, pos) { + size.height = pos.end.top - position.top; + }); + BI.each(top, function (i, pos) { + }); + return size; + }, + + draw: function (position, size, name) { + var self = this; + this.stopDraw(); + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var other = this._getRegionExcept(name); + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(right, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(left, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(middle, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(bottom, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(top, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + }, + + addRegion: function (region, position) { + this.stopDraw(); + return this.arrangement.addRegion(region, position); + }, + + deleteRegion: function (name) { + return this.arrangement.deleteRegion(name); + }, + + setRegionSize: function (name, size) { + size = this.getSize(name, null, size); + return this.arrangement.setRegionSize(name, size); + }, + + setPosition: function (position, size) { + var self = this; + this.stopDraw(); + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(null, position, size); + this.draw(position, size); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + var at = this.arrangement.setPosition(position, size); + return at; + }, + + setRegionPosition: function (name, position) { + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(name, position); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + return this.arrangement.setRegionPosition(name, position); + }, + + setDropPosition: function (position, size) { + var self = this; + this.stopDraw(); + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(null, position, size); + this.draw(position, size); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + var callback = self.arrangement.setDropPosition(position, size); + return function () { + callback(); + self.stopDraw(); + } + }, + + scrollInterval: function () { + this.arrangement.scrollInterval.apply(this.arrangement, arguments); + }, + + scrollEnd: function () { + this.arrangement.scrollEnd.apply(this.arrangement, arguments); + }, + + scrollTo: function (scroll) { + this.arrangement.scrollTo(scroll); + }, + + zoom: function (ratio) { + this.arrangement.zoom(ratio); + }, + + resize: function () { + return this.arrangement.resize(); + }, + + relayout: function () { + return this.arrangement.relayout(); + }, + + setLayoutType: function (type) { + this.arrangement.setLayoutType(type); + }, + + getLayoutType: function () { + return this.arrangement.getLayoutType(); + }, + + getLayoutRatio: function () { + return this.arrangement.getLayoutRatio(); + }, + + getHelper: function () { + return this.arrangement.getHelper(); + }, + + getRegionByName: function (name) { + return this.arrangement.getRegionByName(name); + }, + + getAllRegions: function () { + return this.arrangement.getAllRegions(); + }, + + revoke: function () { + return this.arrangement.revoke(); + }, + + populate: function (items) { + var self = this; + this.arrangement.populate(items); + } +}); +BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE"; +BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL"; +BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/** + * 月份下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.MonthCombo + * @extends BI.Trigger + */ +BI.MonthCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-combo", + behaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.MonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.month_trigger" + }); + + this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { + if (this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getValue()); + } else if (!this.getKey()) { + self.setValue(); + } + self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); + }); + this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.MonthTrigger.EVENT_START, function () { + self.combo.hideView(); + }); + this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + this.trigger.on(BI.MonthTrigger.EVENT_CHANGE, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + + this.popup = BI.createWidget({ + type: "bi.month_popup", + behaviors: o.behaviors + }); + this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + el: this.popup + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); + +BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.month_combo', BI.MonthCombo);/** + * 月份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.MonthPopup + * @extends BI.Trigger + */ +BI.MonthPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-popup", + behaviors: {} + }); + }, + + _init: function () { + BI.MonthPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + //纵向排列月 + var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; + var items = []; + items.push(month.slice(0, 2)); + items.push(month.slice(2, 4)); + items.push(month.slice(4, 6)); + items.push(month.slice(6, 8)); + items.push(month.slice(8, 10)); + items.push(month.slice(10, 12)); + items = BI.map(items, function (i, item) { + return BI.map(item, function (j, td) { + return { + type: "bi.text_item", + cls: "bi-list-item-active", + textAlign: "center", + whiteSpace: "nowrap", + once: false, + forceSelected: true, + height: 23, + width: 38, + value: td, + text: td + 1 + }; + }); + }); + + this.month = BI.createWidget({ + type: "bi.button_group", + element: this, + behaviors: o.behaviors, + items: BI.createItems(items, {}), + layouts: [BI.LogicFactory.createLogic("table", BI.extend({ + dynamic: true + }, { + columns: 2, + rows: 6, + columnSize: [1 / 2, 1 / 2], + rowSize: 25 + })), { + type: "bi.center_adapt", + vgap: 1, + hgap: 2 + }] + }); + + this.month.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MonthPopup.EVENT_CHANGE); + } + }) + }, + + getValue: function () { + return this.month.getValue()[0]; + }, + + setValue: function (v) { + this.month.setValue([v]); + } +}); +BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.month_popup", BI.MonthPopup);/** + * 月份trigger + * + * Created by GUY on 2015/8/21. + * @class BI.MonthTrigger + * @extends BI.Trigger + */ +BI.MonthTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 25, + errorText: BI.i18nText("BI-Month_Trigger_Error_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-month-trigger bi-border", + height: 25 + }); + }, + _init: function () { + BI.MonthTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: c.errorText + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.MonthTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.MonthTrigger.EVENT_CHANGE); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + self.editor.setTitle(value); + } + self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.MonthTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.MonthTrigger.EVENT_STOP); + }); + BI.createWidget({ + element: this, + type: 'bi.htape', + items: [ + { + el: this.editor + }, { + el: { + type: "bi.text_button", + text: BI.i18nText("BI-Multi_Date_Month"), + baseCls: "bi-trigger-month-text", + width: c.triggerWidth + }, + width: c.triggerWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + setValue: function (v) { + if(BI.isNotNull(v)){ + this.editor.setState(v + 1); + this.editor.setValue(v + 1); + this.editor.setTitle(v + 1); + return; + } + this.editor.setState(); + this.editor.setValue(); + this.editor.setTitle(); + }, + getKey: function () { + return this.editor.getValue() | 0; + }, + getValue: function () { + return this.editor.getValue() - 1; + } +}); +BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthTrigger.EVENT_START = "EVENT_START"; +BI.MonthTrigger.EVENT_STOP = "EVENT_STOP"; +BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.month_trigger", BI.MonthTrigger);/** + * @class BI.MultiLayerSelectTreeCombo + * @extends BI.Widget + */ +BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer_select_tree-combo", + isDefaultInit: false, + height: 30, + text: "", + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_select_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); +BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/** + * guy + * 二级树 + * @class BI.MultiLayerSelectLevelTree + * @extends BI.Select + */ +BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-select-level-tree", + isDefaultInit: false, + items: [], + itemsCreator: BI.emptyFn + }) + }, + + _init: function () { + BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _assertId: function (sNodes) { + BI.each(sNodes, function (i, node) { + node.id = node.id || BI.UUID(); + }); + }, + + //构造树结构, + initTree: function (nodes) { + var self = this, o = this.options; + this.empty(); + this._assertId(nodes); + this.tree = BI.createWidget({ + type: "bi.custom_tree", + element: this, + expander: { + type: "bi.select_tree_expander", + isDefaultInit: o.isDefaultInit, + el: {}, + popup: { + type: "bi.custom_tree" + } + }, + + items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), + itemsCreator: o.itemsCreator, + + el: { + type: "bi.button_tree", + chooseType: BI.Selection.Single, + layouts: [{ + type: "bi.vertical" + }] + } + }); + this.tree.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments); + } + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + setValue: function (v) { + this.tree.setValue(v); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + getAllLeaves: function () { + return this.tree.getAllLeaves(); + }, + + getNodeById: function (id) { + return this.tree.getNodeById(id); + }, + + getNodeByValue: function (id) { + return this.tree.getNodeByValue(id); + } +}); +BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/** + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSelectTreePopup + * @extends BI.Pane + */ + +BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-select-tree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + isDefaultInit: false, + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.multilayer_select_level_tree', + isDefaultInit: o.isDefaultInit, + items: o.items, + itemsCreator: o.itemsCreator + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active", + layer: 0,//第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_first_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active", + layer: 0,//第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_last_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active", + layer: 0,//第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_mid_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/** + * 多层级下拉单选树 + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSingleTreeCombo + * @extends BI.Widget + */ +BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-singletree-combo", + isDefaultInit: false, + height: 30, + text: "", + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_single_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); + +BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/** + * guy + * 二级树 + * @class BI.MultiLayerSingleLevelTree + * @extends BI.Single + */ +BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-single-level-tree", + isDefaultInit: false, + items: [], + itemsCreator: BI.emptyFn + }) + }, + + _init: function () { + BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_single_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_single_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _assertId: function (sNodes) { + BI.each(sNodes, function (i, node) { + node.id = node.id || BI.UUID(); + }); + }, + + //构造树结构, + initTree: function (nodes) { + var self = this, o = this.options; + this.empty(); + this._assertId(nodes); + this.tree = BI.createWidget({ + type: "bi.custom_tree", + element: this, + expander: { + isDefaultInit: o.isDefaultInit, + el: {}, + popup: { + type: "bi.custom_tree" + } + }, + + items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (items) { + callback(BI.Tree.transformToTreeFormat(items), 0) + }) + }, + + el: { + type: "bi.button_tree", + chooseType: BI.Selection.Single, + layouts: [{ + type: "bi.vertical" + }] + } + }); + this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v); + } + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + setValue: function (v) { + this.tree.setValue(v); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + getAllLeaves: function () { + return this.tree.getAllLeaves(); + }, + + getNodeById: function (id) { + return this.tree.getNodeById(id); + }, + + getNodeByValue: function (id) { + return this.tree.getNodeByValue(id); + } +}); +BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree); +/** + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSingleTreePopup + * @extends BI.Pane + */ + +BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-singletree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + isDefaultInit: false, + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.multilayer_single_level_tree', + isDefaultInit: o.isDefaultInit, + items: o.items, + itemsCreator: o.itemsCreator + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item", + layer: 0,//第几层级 + id: "", + pId: "", + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.first_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item", + layer: 0,//第几层级 + id: "", + pId: "", + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.last_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item", + layer: 0,//第几层级 + id: "", + pId: "", + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.mid_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeFirstTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.first_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.item.doRedMark.apply(this.item, arguments); + }, + + unRedMark: function () { + this.item.unRedMark.apply(this.item, arguments); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeLastTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.last_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.item.doRedMark.apply(this.item, arguments); + }, + + unRedMark: function () { + this.item.unRedMark.apply(this.item, arguments); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeMidTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.mid_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.item.doRedMark.apply(this.item, arguments); + }, + + unRedMark: function () { + this.item.unRedMark.apply(this.item, arguments); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/** + * + * @class BI.MultiSelectCheckPane + * @extends BI.Widget + */ +BI.MultiSelectCheckPane = BI.inherit(BI.Widget, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-check-pane bi-background", + items: [], + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + onClickContinueSelect: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectCheckPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.storeValue = {}; + this.display = BI.createWidget({ + type: 'bi.display_selected_list', + items: opts.items, + itemsCreator: function (op, callback) { + op = BI.extend(op || {}, { + selectedValues: self.storeValue.value + }); + if (self.storeValue.type === BI.Selection.Multi) { + callback({ + items: BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt + } + }) + }); + return; + } + opts.itemsCreator(op, callback); + } + }); + + this.continueSelect = BI.createWidget({ + type: 'bi.text_button', + text: BI.i18nText('BI-Continue_Select'), + cls: 'multi-select-check-selected bi-high-light' + }); + + this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { + opts.onClickContinueSelect(); + }); + + BI.createWidget({ + type: 'bi.vtape', + element: this, + items: [{ + height: this.constants.height, + el: { + type: 'bi.left', + cls: 'multi-select-continue-select', + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText('BI-Selected_Data') + }, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }, + { + el: this.continueSelect, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }] + } + }, { + height: 'fill', + el: this.display + }] + }); + }, + + setValue: function (v) { + this.storeValue = v || {}; + }, + + empty: function () { + this.display.empty(); + }, + + populate: function () { + this.display.populate.apply(this.display, arguments); + } +}); + +BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/** + * + * + * 查看已选弹出层的展示面板 + * @class BI.DisplaySelectedList + * @extends BI.Widget + */ +BI.DisplaySelectedList = BI.inherit(BI.Pane, { + + constants: { + height: 25, + lgap: 10 + }, + + _defaultConfig: function () { + return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-display-list", + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.DisplaySelectedList.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.hasNext = false; + + this.button_group = BI.createWidget({ + type: "bi.list_pane", + element: this, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + items: this._createItems(opts.items), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + layouts: [{ + type: "bi.vertical", + lgap: 10 + }] + }, + itemsCreator: function (options, callback) { + + opts.itemsCreator(options, function (ob) { + self.hasNext = !!ob.hasNext; + callback(self._createItems(ob.items)); + }) + }, + hasNext: function () { + return self.hasNext; + } + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: 'bi.icon_text_item', + cls: 'cursor-default check-font display-list-item bi-tips', + once: true, + invalid: true, + selected: true, + height: this.constants.height, + logic: { + dynamic: true + } + }); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + if (arguments.length === 0) { + this.button_group.populate(); + } else { + this.button_group.populate(this._createItems(items)); + } + } +}); + +BI.shortcut('bi.display_selected_list', BI.DisplaySelectedList);/** + * + * @class BI.MultiSelectCombo + * @extends BI.Single + */ +BI.MultiSelectCombo = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-combo', + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + height: 28 + }); + }, + + _init: function () { + BI.MultiSelectCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + self.trigger.getCounter().setButtonChecked(self.storeValue); + }; + this.storeValue = {}; + //标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + // adapter: this.popup, + masker: { + offset: { + left: 1, + top: 1, + right: 2, + bottom: 33 + } + }, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (res) { + if (op.times === 1 && BI.isNotNull(op.keywords)) { + //预防trigger内部把当前的storeValue改掉 + self.trigger.setValue(BI.deepClone(self.getValue())); + } + callback.apply(self, arguments); + }); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { + self._setStartValue(""); + this.getSearcher().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { + self._setStartValue(""); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { + if (this.getSearcher().hasMatched()) { + var keyword = this.getSearcher().getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self.combo.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.populate(); + self._setStartValue(""); + }) + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.combo.setValue(self.storeValue); + assertShowValue(); + self.combo.populate(); + self._setStartValue(""); + } else { + self.combo.setValue(self.storeValue); + assertShowValue(); + } + }); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + }); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + this.getCounter().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: 'bi.multi_select_popup_view', + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + onLoaded: function () { + BI.nextTick(function () { + self.combo.adjustWidth(); + self.combo.adjustHeight(); + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + this.setValue(self.storeValue); + BI.nextTick(function () { + self.populate(); + }); + }); + //当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + //important:关闭弹出时又可能没有退出编辑状态 + self.trigger.stopEditing(); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + } + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button bi-border-left" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }) + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, + keywords: keywords + }, function (ob) { + var values = BI.pluck(ob.items, "value"); + digest(values); + }); + + function digest(items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, + keywords: [this.trigger.getKey()] + }, function (ob) { + var items = BI.pluck(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }) + }, + + _adjust: function (callback) { + var self = this, o = this.options; + if (!this._count) { + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH + }, function (res) { + self._count = res.count; + adjust(); + callback(); + }); + } else { + adjust(); + callback(); + } + function adjust() { + if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.Multi, + value: [] + } + } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.All, + value: [] + } + } + if (self.wants2Quit === true) { + self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.popup.setStartValue(value); + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.combo.setValue(this.storeValue); + }, + + getValue: function () { + return this.storeValue; + }, + + populate: function () { + this._count = null; + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.extend(BI.MultiSelectCombo, { + REQ_GET_DATA_LENGTH: 0, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/** + * 多选加载数据面板 + * Created by guy on 15/11/2. + * @class BI.MultiSelectLoader + * @extends Widget + */ +BI.MultiSelectLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-loader', + logic: { + dynamic: true + }, + el: { + height: 400 + }, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + + this.button_group = BI.createWidget({ + type: "bi.select_list", + element: this, + logic: opts.logic, + el: BI.extend({ + onLoaded: opts.onLoaded, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, opts.el), + itemsCreator: function (op, callback) { + var startValue = self._startValue; + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi + ? self.storeValue.value.concat(startValue) : self.storeValue.value + })); + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + } + }); + if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) { + var txt = opts.valueFormatter(startValue) || startValue; + json.unshift({ + text: txt, + value: startValue, + title: txt, + selected: true + }) + } + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { + BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); + self.setValue(self.storeValue); + } + (op.times === 1) && self._scrollToTop(); + }); + }, + hasNext: function () { + return hasNext; + } + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: this.options.logic, + height: 25, + selected: this.isAllSelected() + }) + }, + + _scrollToTop: function () { + var self = this; + BI.delay(function () { + self.button_group.element.scrollTop(0); + }, 30); + }, + + isAllSelected: function () { + return this.button_group.isAllSelected(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + setStartValue: function (v) { + this._startValue = v; + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.button_group.setValue(this.storeValue); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/** + * 带加载的多选下拉面板 + * @class BI.MultiSelectPopupView + * @extends Widget + */ +BI.MultiSelectPopupView = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-popup-view', + maxWidth: 'auto', + minWidth: 135, + maxHeight: 400, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectPopupView.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + + this.loader = BI.createWidget({ + type: "bi.multi_select_loader", + itemsCreator: opts.itemsCreator, + valueFormatter: opts.valueFormatter, + onLoaded: opts.onLoaded + }); + + this.popupView = BI.createWidget({ + type: "bi.multi_popup_view", + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + element: this, + buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')], + el: this.loader + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE); + }); + this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { + switch (index) { + case 0: + self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR); + break; + case 1: + self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM); + break; + } + }); + }, + + isAllSelected: function () { + return this.loader.isAllSelected(); + }, + + setStartValue: function (v) { + this.loader.setStartValue(v); + }, + + setValue: function (v) { + this.popupView.setValue(v); + }, + + getValue: function () { + return this.popupView.getValue(); + }, + + populate: function (items) { + this.popupView.populate.apply(this.popupView, arguments); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; + + +BI.shortcut('bi.multi_select_popup_view', BI.MultiSelectPopupView);/** + * + * 复选下拉框 + * @class BI.MultiSelectTrigger + * @extends BI.Trigger + */ + +BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { + + constants: { + height: 14, + rgap: 4, + lgap: 4 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-trigger bi-border", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + searcher: {}, + switcher: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + if (o.height) { + this.setHeight(o.height - 2); + } + + this.searcher = BI.createWidget(o.searcher, { + type: "bi.multi_select_searcher", + height: o.height, + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + popup: {}, + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_START); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments); + }); + this.numberCounter = BI.createWidget(o.switcher, { + type: 'bi.multi_select_check_selected_switcher', + valueFormatter: o.valueFormatter, + itemsCreator: o.itemsCreator, + adapter: o.adapter, + masker: o.masker + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK); + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW); + }); + + var wrapNumberCounter = BI.createWidget({ + type: 'bi.right_vertical_adapt', + hgap: 4, + items: [{ + el: this.numberCounter + }] + }); + + var wrapper = BI.createWidget({ + type: 'bi.htape', + element: this, + items: [ + { + el: this.searcher, + width: 'fill' + }, { + el: wrapNumberCounter, + width: 0 + }, { + el: BI.createWidget(), + width: 30 + }] + }); + + this.numberCounter.on(BI.Events.VIEW, function (b) { + BI.nextTick(function () {//自动调整宽度 + wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0); + wrapper.resize(); + }); + }); + + this.element.click(function (e) { + if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { + self.numberCounter.hideView(); + } + }); + }, + + getCounter: function () { + return this.numberCounter; + }, + + getSearcher: function () { + return this.searcher; + }, + + stopEditing: function () { + this.searcher.stopSearch(); + this.numberCounter.hideView(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + this.numberCounter.setAdapter(adapter); + }, + + setValue: function (ob) { + this.searcher.setValue(ob); + this.numberCounter.setValue(ob); + }, + + getKey: function () { + return this.searcher.getKey(); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); + +BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; +BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectTrigger.EVENT_START = "EVENT_START"; +BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP"; +BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; + +BI.shortcut('bi.multi_select_trigger', BI.MultiSelectTrigger);/** + * 多选加载数据搜索loader面板 + * Created by guy on 15/11/4. + * @class BI.MultiSelectSearchLoader + * @extends Widget + */ +BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-search-loader', + itemsCreator: BI.emptyFn, + keywordGetter: BI.emptyFn, + valueFormatter: BI.emptyFn, + }); + }, + + _init: function () { + BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + + this.button_group = BI.createWidget({ + type: "bi.select_list", + element: this, + logic: { + dynamic: false + }, + el: { + tipText: BI.i18nText("BI-No_Select"), + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, + itemsCreator: function (op, callback) { + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: self.storeValue.value + })); + opts.itemsCreator(op, function (ob) { + var keyword = ob.keyword = opts.keywordGetter(); + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = self._filterValues(self.storeValue); + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), keyword); + if (op.times === 1 && self.storeValue) { + self.setValue(self.storeValue); + } + }); + }, + hasNext: function () { + return hasNext; + } + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: { + dynamic: false + }, + height: 25, + selected: this.isAllSelected() + }) + }, + + isAllSelected: function () { + return this.button_group.isAllSelected(); + }, + + _filterValues: function (src) { + var o = this.options; + var keyword = o.keywordGetter(); + var values = BI.deepClone(src.value) || []; + var newValues = BI.map(values, function (i, v) { + return { + text: o.valueFormatter(v) || v, + value: v + }; + }); + if (BI.isKey(keyword)) { + var search = BI.Func.getSearchResult(newValues, keyword); + values = search.matched.concat(search.finded); + } + return BI.map(values, function (i, v) { + return { + text: v.text, + title: v.text, + value: v.value, + selected: src.type === BI.Selection.All + } + }) + }, + + setValue: function (v) { + //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 + this.storeValue = BI.deepClone(v); + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_select_search_loader', BI.MultiSelectSearchLoader);/** + * + * 在搜索框中输入文本弹出的面板 + * @class BI.MultiSelectSearchPane + * @extends Widget + */ + +BI.MultiSelectSearchPane = BI.inherit(BI.Widget, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-search-pane bi-card", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + keywordGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectSearchPane.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.tooltipClick = BI.createWidget({ + type: "bi.label", + invisible: true, + text: BI.i18nText('BI-Click_Blank_To_Select'), + cls: 'multi-select-toolbar', + height: this.constants.height + }); + + this.loader = BI.createWidget({ + type: "bi.multi_select_search_loader", + keywordGetter: o.keywordGetter, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator.apply(self, [op, function (res) { + callback(res); + self.setKeyword(o.keywordGetter()); + }]); + } + }); + this.loader.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.resizer = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.tooltipClick, + height: 0 + }, { + el: this.loader + }] + }); + this.tooltipClick.setVisible(false); + }, + + setKeyword: function (keyword) { + var btn; + var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); + if (isVisible !== this.tooltipClick.isVisible()) { + this.tooltipClick.setVisible(isVisible); + this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); + this.resizer.resize(); + } + }, + + isAllSelected: function () { + return this.loader.isAllSelected(); + }, + + hasMatched: function () { + return this.tooltipClick.isVisible(); + }, + + setValue: function (v) { + this.loader.setValue(v); + }, + + getValue: function () { + return this.loader.getValue(); + }, + + empty: function () { + this.loader.empty(); + }, + + populate: function (items) { + this.loader.populate.apply(this.loader, arguments); + } +}); + +BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/** + * 查看已选按钮 + * Created by guy on 15/11/3. + * @class BI.MultiSelectCheckSelectedButton + * @extends BI.Single + */ +BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-check-selected-button bi-high-light', + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments); + var self = this; + this.numberCounter = BI.createWidget({ + type: 'bi.text_button', + element: this, + hgap: 4, + text: "0", + textAlign: 'center', + textHeight: 15 + }); + this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments); + }); + + this.numberCounter.element.hover(function () { + self.numberCounter.setTag(self.numberCounter.getText()); + self.numberCounter.setText(self._const.checkSelected); + }, function () { + self.numberCounter.setText(self.numberCounter.getTag()); + }); + this.setVisible(false); + }, + + setValue: function (ob) { + var self = this, o = this.options; + ob || (ob = {}); + ob.type || (ob.type = BI.Selection.Multi); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH + }, function (res) { + var length = res.count - ob.value.length; + BI.nextTick(function(){ + self.numberCounter.setText(length); + self.setVisible(length > 0); + }); + }); + return; + } + BI.nextTick(function(){ + self.numberCounter.setText(ob.value.length); + self.setVisible(ob.value.length > 0); + }) + }, + + getValue: function () { + + } +}); + +BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_select_check_selected_button', BI.MultiSelectCheckSelectedButton);/** + * 多选输入框 + * Created by guy on 15/11/3. + * @class BI.MultiSelectEditor + * @extends Widget + */ +BI.MultiSelectEditor = BI.inherit(BI.Widget, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-editor', + el: {} + }); + }, + + _init: function () { + BI.MultiSelectEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: 'bi.state_editor', + element: this, + height: o.height, + watermark: BI.i18nText('BI-Basic_Search'), + allowBlank: true + }); + + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.editor.on(BI.StateEditor.EVENT_PAUSE, function () { + self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE); + }); + this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () { + + }); + }, + + focus: function () { + this.editor.focus(); + }, + + blur: function () { + this.editor.blur(); + }, + + setState: function (state) { + this.editor.setState(state); + }, + + setValue: function (v) { + this.editor.setValue(v); + }, + + getValue: function () { + var v = this.editor.getState(); + if (BI.isArray(v) && v.length > 0) { + return v[v.length - 1]; + } else { + return ""; + } + }, + + getKeywords: function () { + var val = this.editor.getLastValidValue(); + var keywords = val.match(/[\S]+/g); + if (BI.isEndWithBlank(val)) { + return keywords.concat([' ']); + } + return keywords; + }, + + populate: function (items) { + + } +}); +BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE"; +BI.shortcut('bi.multi_select_editor', BI.MultiSelectEditor);/** + * searcher + * Created by guy on 15/11/3. + * @class BI.MultiSelectSearcher + * @extends Widget + */ +BI.MultiSelectSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-searcher', + itemsCreator: BI.emptyFn, + el: {}, + popup: {}, + valueFormatter: BI.emptyFn, + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: 'bi.multi_select_editor', + height: o.height + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + height: o.height, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.multi_select_search_pane", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.editor.getValue(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); + } + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments); + }); + this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { + var keywords = this.getKeywords(); + self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords); + }); + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + setState: function (ob) { + var o = this.options; + ob || (ob = {}); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + if (BI.size(ob.assist) === 1) { + this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + "")); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); + } + } else { + if (BI.size(ob.value) === 1) { + this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + "")); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); + } + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectSearcher.EVENT_START = "EVENT_START"; +BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP"; +BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.shortcut('bi.multi_select_searcher', BI.MultiSelectSearcher);/** + * 查看已选switcher + * Created by guy on 15/11/3. + * @class BI.MultiSelectCheckSelectedSwitcher + * @extends Widget + */ +BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-check-selected-switcher', + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + el: {}, + popup: {}, + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.button = BI.createWidget(o.el, { + type: "bi.multi_select_check_selected_button", + itemsCreator: o.itemsCreator + }); + this.button.on(BI.Events.VIEW, function () { + self.fireEvent(BI.Events.VIEW, arguments); + }); + this.switcher = BI.createWidget({ + type: "bi.switcher", + toggle: false, + element: this, + el: this.button, + popup: BI.extend({ + type: "bi.multi_select_check_pane", + valueFormatter: o.valueFormatter, + itemsCreator: o.itemsCreator, + onClickContinueSelect: function () { + self.switcher.hideView(); + } + }, o.popup), + adapter: o.adapter, + masker: o.masker + }); + this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE); + }); + this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW); + }); + this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () { + var me = this; + BI.nextTick(function () { + me.populate(); + }); + }); + + this.switcher.element.click(function (e) { + e.stopPropagation(); + }); + }, + + adjustView: function () { + this.switcher.adjustView(); + }, + + hideView: function () { + this.switcher.empty(); + this.switcher.hideView(); + }, + + setAdapter: function (adapter) { + this.switcher.setAdapter(adapter); + }, + + setValue: function (v) { + this.switcher.setValue(v); + }, + + setButtonChecked: function (v) { + this.button.setValue(v) + }, + + getValue: function () { + + }, + + populate: function (items) { + this.switcher.populate.apply(this.switcher, arguments); + } +}); + +BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; +BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** + * Created by zcf_1 on 2017/5/2. + */ +BI.MultiSelectList = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-list', + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn + }) + }, + _init: function () { + BI.MultiSelectList.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + this.storeValue = {}; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + // self.trigger.setValue(self.storeValue); + }; + + this.adapter = BI.createWidget({ + type: "bi.multi_select_loader", + cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + // onLoaded: o.onLoaded, + el: { + height: "" + } + }); + this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }); + }); + + this.searcherPane = BI.createWidget({ + type: "bi.multi_select_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.trigger.getKeyword(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self._setStartValue(""); + this.setValue(BI.deepClone(self.storeValue)); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(""); + self.adapter.setValue(self.storeValue); + //需要刷新回到初始界面,否则搜索的结果不能放在最前面 + self.adapter.populate(); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + if (this.hasMatched()) { + var keyword = this.getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self._setStartValue(""); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }) + } else { + self._showAdapter(); + } + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeyword(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + } else { + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () {//安徽省 北京 + assertShowValue(); + }); + } + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.trigger, + height: 30 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }) + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + if (!this._allData) { + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_ALL_DATA + }, function (ob) { + self._allData = BI.pluck(ob.items, "value"); + digest(self._allData); + }) + } else { + digest(this._allData) + } + + function digest(items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_ALL_DATA, + keyword: self.trigger.getKeyword() + }, function (ob) { + var items = BI.pluck(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }) + }, + + _adjust: function (callback) { + var self = this, o = this.options; + if (!this._count) { + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_DATA_LENGTH + }, function (res) { + self._count = res.count; + adjust(); + callback(); + }); + } else { + adjust(); + callback(); + } + function adjust() { + if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.Multi, + value: [] + } + } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.All, + value: [] + } + } + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.adapter.setStartValue(value); + }, + + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, + + resize: function () { + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); + }, + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.adapter.setValue(this.storeValue); + this.trigger.setValue(this.storeValue); + }, + + getValue: function () { + return this.storeValue; + }, + + populate: function () { + this._count = null; + this._allData = null; + this.adapter.populate.apply(this.adapter, arguments); + this.trigger.populate.apply(this.trigger, arguments); + } +}); + +BI.extend(BI.MultiSelectList, { + REQ_GET_DATA_LENGTH: 0, + REQ_GET_ALL_DATA: -1 +}); + +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 + }) + }, + + _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.searcher.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.setSelectedValue(self.storeValue.value); + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + }); + + //搜索中的时候用的是parttree,同adapter中的synctree不一样 + this.searcherPane = BI.createWidget({ + type: "bi.multi_tree_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + keywordGetter: function () { + return self.searcher.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.searcher.getKeyword(); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.searcher.getKeyword() + }); + }, + adapter: this.adapter, + popup: this.searcherPane, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + // self.storeValue = {value: self.adapter.getValue()}; + // self.searcherPane.setSelectedValue(self.storeValue.value); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + // self.storeValue = {value: self.searcherPane.getValue()}; + // self.adapter.setSelectedValue(self.storeValue.value); + BI.nextTick(function () { + self.adapter.populate(); + }); + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + if (self.searcher.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.setSelectedValue(self.storeValue.value); + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + self._showAdapter(); + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.searcher, + height: 30 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + 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 () { + + }, + + setSelectedValue: function (v) { + this.storeValue.value = v || {}; + this.adapter.setSelectedValue(v); + this.searcherPane.setSelectedValue(v); + this.searcher.setValue({ + value: v || {} + }); + }, + + setValue: function (v) { + this.adapter.setValue(v); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + updateValue: function (v) { + this.adapter.updateValue(v); + }, + + getValue: function () { + return this.storeValue.value; + }, + + populate: function () { + this.searcher.populate.apply(this.searcher, 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", + 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); + }, + + setSelectedValue: function (v) { + v || (v = {}); + this.popup.setSelectedValue(v); + }, + + updateValue: function (v) { + this.popup.updateValue(v); + this.popup.refresh(); + }, + + 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 + */ +BI.MultiTreeCheckPane = BI.inherit(BI.Pane, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-check-pane bi-background", + onClickContinueSelect: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeCheckPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.selectedValues = {}; + + var continueSelect = BI.createWidget({ + type: 'bi.text_button', + text: BI.i18nText('BI-Continue_Select'), + cls: 'multi-tree-check-selected' + }); + continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { + opts.onClickContinueSelect(); + BI.nextTick(function () { + self.empty(); + }); + }); + + var backToPopup = BI.createWidget({ + type: 'bi.left', + cls: 'multi-tree-continue-select', + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText('BI-Selected_Data') + }, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }, + { + el: continueSelect, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }] + }); + + this.display = BI.createWidget({ + type: "bi.display_tree", + cls: "bi-multi-tree-display", + itemsCreator: function (op, callback) { + op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA; + opts.itemsCreator(op, callback); + } + }); + + this.display.on(BI.Events.AFTERINIT, function () { + self.fireEvent(BI.Events.AFTERINIT); + }); + + this.display.on(BI.TreeView.EVENT_INIT, function () { + backToPopup.setVisible(false); + }); + + this.display.on(BI.TreeView.EVENT_AFTERINIT, function () { + backToPopup.setVisible(true); + }); + + BI.createWidget({ + type: 'bi.vtape', + element: this, + items: [{ + height: this.constants.height, + el: backToPopup + }, { + height: 'fill', + el: this.display + }] + }); + + }, + + empty: function () { + this.display.empty(); + }, + + populate: function (configs) { + this.display.stroke(configs); + }, + + setValue: function (v) { + v || (v = {}); + this.display.setSelectedValue(v.value); + }, + + getValue: function () { + + } +}); + +BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK"; + + +BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/** + * + * @class BI.MultiTreeCombo + * @extends BI.Single + */ + +BI.MultiTreeCombo = BI.inherit(BI.Single, { + + constants: { + offset: { + top: 1, + left: 1, + right: 2, + bottom: 33 + } + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-combo', + itemsCreator: BI.emptyFn, + height: 25 + }); + }, + + _init: function () { + BI.MultiTreeCombo.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + var isInit = false; + var want2showCounter = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + // adapter: this.popup, + masker: { + offset: this.constants.offset + }, + searcher: { + type: "bi.multi_tree_searcher", + itemsCreator: o.itemsCreator + }, + switcher: { + el: { + type: "bi.multi_tree_check_selected_button" + }, + popup: { + type: "bi.multi_tree_check_pane", + itemsCreator: o.itemsCreator + } + } + + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: 'bi.multi_tree_popup_view', + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiTreePopup.EVENT_AFTERINIT, + action: function () { + self.trigger.getCounter().adjustView(); + isInit = true; + if (want2showCounter === true) { + showCounter(); + } + } + }, { + eventName: BI.MultiTreePopup.EVENT_CHANGE, + action: function () { + change = true; + var val = { + type: BI.Selection.Multi, + value: this.hasChecked() ? {1: 1} : {} + }; + self.trigger.getSearcher().setState(val); + self.trigger.getCounter().setButtonChecked(val); + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, + action: function () { + self.combo.hideView(); + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, + action: function () { + clear = true; + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: o.itemsCreator, + onLoaded: function () { + BI.nextTick(function () { + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.storeValue = {value: {}}; + var change = false; + var clear = false; //标识当前是否点击了清空 + + var isSearching = function () { + return self.trigger.getSearcher().isSearching(); + }; + + var isPopupView = function () { + return self.combo.isViewVisible(); + }; + + this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { + self.storeValue = {value: self.combo.getValue()}; + this.setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { + self.storeValue = {value: this.getValue()}; + self.combo.setValue(self.storeValue); + BI.nextTick(function () { + if (isPopupView()) { + self.combo.populate(); + } + }); + }); + function showCounter() { + if (isSearching()) { + self.storeValue = {value: self.trigger.getValue()}; + } else if (isPopupView()) { + self.storeValue = {value: self.combo.getValue()}; + } + self.trigger.setValue(self.storeValue); + } + + this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + if (want2showCounter === false) { + want2showCounter = true; + } + if (isInit === true) { + want2showCounter = null; + showCounter(); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () { + var val = { + type: BI.Selection.Multi, + value: this.getSearcher().hasChecked() ? {1: 1} : {} + }; + this.getSearcher().setState(val); + this.getCounter().setButtonChecked(val); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + if (isSearching()) { + return; + } + if (change === true) { + self.storeValue = {value: self.combo.getValue()}; + change = false; + } + self.combo.setValue(self.storeValue); + self.populate(); + + }); + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + if (isSearching()) { + self.trigger.stopEditing(); + self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); + }else{ + if (isPopupView()) { + self.trigger.stopEditing(); + self.storeValue = {value: self.combo.getValue()}; + if (clear === true) { + self.storeValue = {value: {}}; + } + self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); + } + } + clear = false; + change = false; + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button bi-border-left" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }) + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + setValue: function (v) { + this.storeValue.value = v || {}; + this.combo.setValue({ + value: v || {} + }); + }, + + getValue: function () { + return this.storeValue.value; + }, + + populate: function () { + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM"; + +BI.shortcut('bi.multi_tree_combo', BI.MultiTreeCombo);/** + * 带加载的多选下拉面板 + * @class BI.MultiTreePopup + * @extends BI.Pane + */ +BI.MultiTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-popup', + maxWidth: 'auto', + minWidth: 100, + maxHeight: 400, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreePopup.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.selectedValues = {}; + + this.tree = BI.createWidget({ + type: "bi.async_tree", + height: 400, + cls:"popup-view-tree", + itemsCreator: opts.itemsCreator, + onLoaded: opts.onLoaded + }); + + this.popupView = BI.createWidget({ + type: "bi.multi_popup_view", + element: this, + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')], + el: this.tree + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { + switch (index) { + case 0: + self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR); + break; + case 1: + self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM); + break; + } + }); + + this.tree.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE); + }); + + this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () { + self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT); + }); + + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v || (v = {}); + this.tree.setSelectedValue(v.value); + }, + + populate: function (config) { + this.tree.stroke(config); + }, + + hasChecked: function () { + return this.tree.hasChecked(); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; +BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT"; + + +BI.shortcut('bi.multi_tree_popup_view', BI.MultiTreePopup);/** + * + * 在搜索框中输入文本弹出的面板 + * @class BI.MultiTreeSearchPane + * @extends BI.Pane + */ + +BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-search-pane bi-card", + itemsCreator: BI.emptyFn, + keywordGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeSearchPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.partTree = BI.createWidget({ + type: "bi.part_tree", + element: this, + tipText: BI.i18nText("BI-No_Select"), + itemsCreator: function (op, callback) { + op.keyword = opts.keywordGetter(); + opts.itemsCreator(op, callback); + } + }); + + this.partTree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.partTree.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); + }); + }, + + hasChecked: function () { + return this.partTree.hasChecked(); + }, + + setValue: function (v) { + this.setSelectedValue(v.value); + }, + + setSelectedValue: function (v) { + v || (v = {}); + this.partTree.setSelectedValue(v); + }, + + getValue: function () { + return this.partTree.getValue(); + }, + + empty: function () { + this.partTree.empty(); + }, + + populate: function (op) { + this.partTree.stroke.apply(this.partTree, arguments); + } +}); + +BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; + +BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/** + * 查看已选按钮 + * Created by guy on 15/11/3. + * @class BI.MultiTreeCheckSelectedButton + * @extends BI.Single + */ +BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-check-selected-button', + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments); + var self = this; + this.indicator = BI.createWidget({ + type: 'bi.icon_button', + cls: 'check-font trigger-check-selected', + width: 15, + height: 15, + stopPropagation: true + }); + + this.checkSelected = BI.createWidget({ + type: 'bi.text_button', + cls: "trigger-check-selected", + invisible: true, + hgap: 4, + text: this._const.checkSelected, + textAlign: 'center', + textHeight: 15 + }); + this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + type: "bi.horizontal", + element: this, + items: [this.indicator, this.checkSelected] + }) + + this.element.hover(function () { + self.indicator.setVisible(false); + self.checkSelected.setVisible(true); + }, function () { + self.indicator.setVisible(true); + self.checkSelected.setVisible(false); + }); + this.setVisible(false); + }, + + setValue: function (v) { + v || (v = {}); + this.setVisible(BI.size(v.value) > 0); + } +}); + +BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_tree_check_selected_button', BI.MultiTreeCheckSelectedButton);/** + * searcher + * Created by guy on 15/11/3. + * @class BI.MultiTreeSearcher + * @extends Widget + */ +BI.MultiTreeSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-searcher', + itemsCreator: BI.emptyFn, + popup: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiTreeSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: 'bi.multi_select_editor', + height: o.height, + el: { + type: "bi.simple_state_editor", + height: o.height + } + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.editor.getValue() + }); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.multi_tree_search_pane", + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.editor.getValue(); + o.itemsCreator(op, callback); + } + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments); + }); + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setState: function (ob) { + ob || (ob = {}); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +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);//小于号的值为:0,小于等于号的值为:1 +//closeMIn:最小值的符号,closeMax:最大值的符号 +/** + * Created by roy on 15/9/17. + * + */ +BI.NumericalInterval = BI.inherit(BI.Single, { + constants: { + typeError: "typeBubble", + numberError: "numberBubble", + signalError: "signalBubble", + editorWidth: 114, + columns: 5, + width: 30, + rows: 1, + numberErrorCls: "number-error", + border: 1, + less: 0, + less_equal: 1, + numTip: "" + }, + _defaultConfig: function () { + var conf = BI.NumericalInterval.superclass._defaultConfig.apply(this, arguments) + return BI.extend(conf, { + extraCls: "bi-numerical-interval", + height: 25, + validation: "valid" + }) + }, + _init: function () { + var self = this, c = this.constants, o = this.options; + BI.NumericalInterval.superclass._init.apply(this, arguments) + this.smallEditor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.min, + level: "warning", + tipType: "warning", + quitChecker: function () { + return false; + }, + validationChecker: function (v) { + if (!BI.isNumeric(v)) { + self.smallEditorBubbleType = c.typeError; + return false; + } + return true; + }, + cls: "numerical-interval-small-editor bi-border-top bi-border-bottom bi-border-left" + }); + + this.smallTip = BI.createWidget({ + type: "bi.label", + text: o.numTip, + height: o.height - 2, + invisible: true + }); + BI.createWidget({ + type: "bi.absolute", + element: this.smallEditor.element, + items: [{ + el: this.smallTip, + top: 0, + right: 5 + }] + }); + + this.bigEditor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.max, + level: "warning", + tipType: "warning", + quitChecker: function () { + return false; + }, + validationChecker: function (v) { + if (!BI.isNumeric(v)) { + self.bigEditorBubbleType = c.typeError; + return false; + } + return true; + }, + cls: "numerical-interval-big-editor bi-border-top bi-border-bottom bi-border-right" + }); + + this.bigTip = BI.createWidget({ + type: "bi.label", + text: o.numTip, + height: o.height - 2, + invisible: true + }); + BI.createWidget({ + type: "bi.absolute", + element: this.bigEditor.element, + items: [{ + el: this.bigTip, + top: 0, + right: 5 + }] + }); + + //this.smallCombo = BI.createWidget({ + // type: "bi.numerical_interval_combo", + // cls: "numerical-interval-small-combo", + // height: o.height, + // value: o.closemin ? 1 : 0, + // offsetStyle: "left" + //}); + // + //this.bigCombo = BI.createWidget({ + // type: "bi.numerical_interval_combo", + // cls: "numerical-interval-big-combo", + // height: o.height, + // value: o.closemax ? 1 : 0, + // offsetStyle: "left" + //}); + this.smallCombo = BI.createWidget({ + type: "bi.icon_combo", + cls: "numerical-interval-small-combo bi-border", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconClass: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconClass: "less-equal-font" + }] + }); + if (o.closemin === true) { + this.smallCombo.setValue(1); + } else { + this.smallCombo.setValue(0); + } + this.bigCombo = BI.createWidget({ + type: "bi.icon_combo", + cls: "numerical-interval-big-combo bi-border", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconClass: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconClass: "less-equal-font" + }] + }); + if (o.closemax === true) { + this.bigCombo.setValue(1); + } else { + this.bigCombo.setValue(0); + } + this.label = BI.createWidget({ + type: "bi.label", + text: BI.i18nText("BI-Basic_Value"), + textHeight: o.height - c.border * 2, + width: c.width - c.border * 2, + height: o.height - c.border * 2, + level: "warning", + tipType: "warning" + }); + this.left = BI.createWidget({ + type: "bi.htape", + items: [{ + el: self.smallEditor + }, { + el: self.smallCombo, + width: c.width - c.border * 2 + }] + + }); + this.right = BI.createWidget({ + type: "bi.htape", + items: [{ + el: self.bigCombo, + width: c.width - c.border * 2 + }, { + el: self.bigEditor + }] + }); + + + BI.createWidget({ + element: self, + type: "bi.center", + hgap: 15, + height: o.height, + items: [ + { + type: "bi.absolute", + items: [{ + el: self.left, + left: -15, + right: 0, + top: 0, + bottom: 0 + }] + }, { + type: "bi.absolute", + items: [{ + el: self.right, + left: 0, + right: -15, + top: 0, + bottom: 0 + }] + } + ] + }); + + BI.createWidget({ + element: self, + type: "bi.horizontal_auto", + items: [ + self.label + ] + }); + + + self._setValidEvent(self.bigEditor, c.bigEditor); + self._setValidEvent(self.smallEditor, c.smallEditor); + self._setErrorEvent(self.bigEditor, c.bigEditor); + self._setErrorEvent(self.smallEditor, c.smallEditor); + self._setBlurEvent(self.bigEditor); + self._setBlurEvent(self.smallEditor); + self._setFocusEvent(self.bigEditor); + self._setFocusEvent(self.smallEditor); + self._setComboValueChangedEvent(self.bigCombo); + self._setComboValueChangedEvent(self.smallCombo); + self._setEditorValueChangedEvent(self.bigEditor); + self._setEditorValueChangedEvent(self.smallEditor); + }, + + _checkValidation: function () { + var self = this, c = this.constants, o = this.options; + self._setTitle(""); + BI.Bubbles.hide(c.typeError); + BI.Bubbles.hide(c.numberError); + BI.Bubbles.hide(c.signalError); + if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) { + self.element.removeClass("number-error"); + o.validation = "invalid"; + return c.typeError; + } else { + if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } else { + var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()), + bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue(); + if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) { + if (smallValue > bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.numberError; + } else { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } + } else { + if (smallValue > bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.numberError; + } else if (smallValue === bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.signalError; + } else { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } + } + } + + } + }, + + _setTitle: function (v) { + var self = this; + self.bigEditor.setTitle(v); + self.smallEditor.setTitle(v); + self.label.setTitle(v); + }, + + _setFocusEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_FOCUS, function () { + self._setTitle(""); + switch (self._checkValidation()) { + case c.typeError: + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "center" + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + break; + default : + return + } + + }) + }, + _setBlurEvent: function (w) { + var c = this.constants, self = this; + w.on(BI.Editor.EVENT_BLUR, function () { + BI.Bubbles.hide(c.typeError); + BI.Bubbles.hide(c.numberError); + BI.Bubbles.hide(c.signalError); + switch (self._checkValidation()) { + case c.typeError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); + break; + case c.numberError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); + break; + case c.signalError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); + break; + default: + self._setTitle(""); + } + }) + }, + + _setErrorEvent: function (w) { + var c = this.constants, self = this + w.on(BI.Editor.EVENT_ERROR, function () { + self._checkValidation(); + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + }) + }, + + + _setValidEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_VALID, function () { + switch (self._checkValidation()) { + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + default: + self.fireEvent(BI.NumericalInterval.EVENT_VALID); + } + }) + }, + + + _setEditorValueChangedEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_CHANGE, function () { + switch (self._checkValidation()) { + case c.typeError: + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "center" + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + break; + default : + break; + } + self.fireEvent(BI.NumericalInterval.EVENT_CHANGE); + }); + }, + + _setComboValueChangedEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.IconCombo.EVENT_CHANGE, function () { + switch (self._checkValidation()) { + case c.typeError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + case c.numberError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + case c.signalError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + default : + self.fireEvent(BI.NumericalInterval.EVENT_CHANGE); + self.fireEvent(BI.NumericalInterval.EVENT_VALID); + } + }) + }, + + isStateValid: function () { + return this.options.validation === "valid"; + }, + + setMinEnable: function (b) { + this.smallEditor.setEnable(b); + }, + + setCloseMinEnable: function (b) { + this.smallCombo.setEnable(b); + }, + + setMaxEnable: function (b) { + this.bigEditor.setEnable(b); + }, + + setCloseMaxEnable: function (b) { + this.bigCombo.setEnable(b); + }, + + showNumTip: function () { + this.smallTip.setVisible(true); + this.bigTip.setVisible(true); + }, + + hideNumTip: function () { + this.smallTip.setVisible(false); + this.bigTip.setVisible(false); + }, + + setNumTip: function(numTip) { + this.smallTip.setText(numTip); + this.bigTip.setText(numTip); + }, + + getNumTip: function() { + return this.smallTip.getText(); + }, + + setValue: function (data) { + data = data || {}; + var self = this, combo_value; + if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) { + self.smallEditor.setValue(data.min); + } + + if (!BI.isNotNull(data.min)) { + self.smallEditor.setValue(""); + } + + if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) { + self.bigEditor.setValue(data.max); + } + + if (!BI.isNotNull(data.max)) { + self.bigEditor.setValue(""); + } + + if (!BI.isNull(data.closemin)) { + if (data.closemin === true) { + combo_value = 1 + } else { + combo_value = 0 + } + self.smallCombo.setValue(combo_value); + } + + if (!BI.isNull(data.closemax)) { + if (data.closemax === true) { + combo_value = 1 + } else { + combo_value = 0 + } + self.bigCombo.setValue(combo_value); + } + }, + + + getValue: function () { + var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue(); + value.min = self.smallEditor.getValue(); + value.max = self.bigEditor.getValue(); + if (minComboValue[0] === 0) { + value.closemin = false + } else { + value.closemin = true + } + + if (maxComboValue[0] === 0) { + value.closemax = false + } else { + value.closemax = true + } + return value; + } +}); +BI.NumericalInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.NumericalInterval.EVENT_VALID = "EVENT_VALID"; +BI.NumericalInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.shortcut("bi.numerical_interval", BI.NumericalInterval);/** + * + * 表格 + * + * Created by GUY on 2015/9/22. + * @class BI.PageTableCell + * @extends BI.Single + */ +BI.PageTableCell = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table-cell", + text: "", + title: "" + }) + }, + + _init: function () { + BI.PageTableCell.superclass._init.apply(this, arguments); + var label = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "nowrap", + height: this.options.height, + text: this.options.text, + title: this.options.title, + value: this.options.value, + lgap: 5, + rgap: 5 + }); + + if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) { + this.element.css(this.options.styles); + } + } +}); + +BI.shortcut("bi.page_table_cell", BI.PageTableCell);/** + * 分页表格 + * + * Created by GUY on 2016/2/15. + * @class BI.PageTable + * @extends BI.Widget + */ +BI.PageTable = BI.inherit(BI.Widget, { + + _const: { + scrollWidth: 18, + minScrollWidth: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table", + el: { + type: "bi.sequence_table" + }, + pager: { + horizontal: { + pages: false, //总页数 + curr: 1, //初始化当前页, pages为数字时可用 + + hasPrev: BI.emptyFn, + hasNext: BI.emptyFn, + firstPage: 1, + lastPage: BI.emptyFn + }, + vertical: { + pages: false, //总页数 + curr: 1, //初始化当前页, pages为数字时可用 + + hasPrev: BI.emptyFn, + hasNext: BI.emptyFn, + firstPage: 1, + lastPage: BI.emptyFn + } + }, + + itemsCreator: BI.emptyFn, + + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.PageTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.hCurr = 1; + this.vCurr = 1; + + this.table = BI.createWidget(o.el, { + type: "bi.sequence_table", + width: o.width, + height: o.height && o.height - 30, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.pager = BI.createWidget(o.pager, { + type: "bi.direction_pager", + height: 30 + }); + this.pager.on(BI.Pager.EVENT_CHANGE, function () { + var vpage = this.getVPage && this.getVPage(); + if (BI.isNull(vpage)) { + vpage = this.getCurrentPage(); + } + var hpage = this.getHPage && this.getHPage(); + o.itemsCreator({ + vpage: vpage, + hpage: hpage + }, function (items, header, crossItems, crossHeader) { + self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage); + self.table.setHPage && self.table.setHPage(hpage); + self.populate.apply(self, arguments); + }); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.table, + left: 0, + top: 0 + }, { + el: this.pager, + left: 0, + right: 0, + bottom: 0 + }] + }) + }, + + setHPage: function (v) { + this.hCurr = v; + this.pager.setHPage && this.pager.setHPage(v); + this.table.setHPage && this.table.setHPage(v); + }, + + setVPage: function (v) { + this.vCurr = v; + this.pager.setVPage && this.pager.setVPage(v); + this.table.setVPage && this.table.setVPage(v); + }, + + getHPage: function () { + var hpage = this.pager.getHPage && this.pager.getHPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + hpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + return this.hpage; + }, + + getVPage: function () { + var vpage = this.pager.getVPage && this.pager.getVPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + vpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + return this.vpage; + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + var showPager = false; + if (this.pager.alwaysShowPager) { + showPager = true; + } else if (this.pager.hasHNext && this.pager.hasHNext()) { + showPager = true; + } else if (this.pager.hasHPrev && this.pager.hasHPrev()) { + showPager = true; + } else if (this.pager.hasVNext && this.pager.hasVNext()) { + showPager = true; + } else if (this.pager.hasVPrev && this.pager.hasVPrev()) { + showPager = true; + } else if (this.pager.hasNext && this.pager.hasNext()) { + showPager = true; + } else if (this.pager.hasPrev && this.pager.hasPrev()) { + showPager = true; + } + this.table.setHeight(height - (showPager ? 30 : 0)); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + restore: function () { + this.table.restore(); + }, + + attr: function () { + BI.PageTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function () { + this.pager.populate(); + this.table.populate.apply(this.table, arguments); + }, + + destroy: function () { + this.table.destroy(); + this.pager && this.pager.destroy(); + BI.PageTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.page_table', BI.PageTable);/** + * 路径选择 + * + * Created by GUY on 2015/12/4. + * @class BI.PathChooser + * @extends BI.Widget + */ +BI.PathChooser = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#d4dadd", + selectLineColor: "#3f8ce8" + }, + + _defaultConfig: function () { + return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-path-chooser", + items: [] + }) + }, + + _init: function () { + BI.PathChooser.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + _createRegions: function (regions) { + var self = this; + this.regions = BI.createWidgets(BI.map(regions, function (i, region) { + return { + type: "bi.path_region", + title: self.texts[region] || region + } + })); + this.regionMap = {}; + BI.each(regions, function (i, region) { + self.regionMap[region] = i; + }); + this.container = BI.createWidget({ + type: "bi.horizontal", + verticalAlign: "top", + scrollx: false, + scrolly: false, + hgap: 10, + items: this.regions + }); + BI.createWidget({ + type: "bi.vertical_adapt", + element: this, + scrollable: true, + hgap: 10, + items: [this.container] + }); + }, + + getRegionIndexById: function (id) { + var node = this.store[id]; + var regionType = node.get("region"); + return this.regionMap[regionType]; + }, + + _drawPath: function (start, offset, index) { + var self = this; + var starts = []; + if (BI.contains(this.start, start)) { + starts = this.start; + } else { + starts = [start]; + } + + BI.each(starts, function (i, s) { + BI.each(self.radios[s], function (i, rad) { + rad.setSelected(false); + }); + BI.each(self.lines[s], function (i, line) { + line.attr("stroke", self._const.lineColor); + }); + BI.each(self.regionIndexes[s], function (i, idx) { + self.regions[idx].reset(); + }); + }); + + BI.each(this.routes[start][index], function (i, id) { + var regionIndex = self.getRegionIndexById(id); + self.regions[regionIndex].setSelect(offset + index, id); + }); + var current = BI.last(this.routes[start][index]); + + while (current && this.routes[current] && this.routes[current].length === 1) { + BI.each(this.routes[current][0], function (i, id) { + var regionIndex = self.getRegionIndexById(id); + self.regions[regionIndex].setSelect(0, id); + }); + this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront(); + current = BI.last(this.routes[current][0]); + } + this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront(); + this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true); + }, + + _drawRadio: function (start, offset, index, x, y) { + var self = this; + var radio = BI.createWidget({ + type: "bi.radio", + cls: "path-chooser-radio", + selected: offset + index === 0, + start: start, + index: index + }); + radio.on(BI.Radio.EVENT_CHANGE, function () { + self._drawPath(start, offset, index); + self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index); + }); + if (!this.radios[start]) { + this.radios[start] = []; + } + this.radios[start].push(radio); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [{ + el: radio, + left: x - 6.5, + top: y - 6.5 + }] + }) + }, + + _drawLine: function (start, lines) { + var self = this; + if (!this.lines[start]) { + this.lines[start] = []; + } + if (!this.pathes[start]) { + this.pathes[start] = []; + } + var startRegionIndex = this.getRegionIndexById(start); + //start所在的位置,然后接着往下画其他的路径 + var offset = this.regions[startRegionIndex].getIndexByValue(start); + BI.each(lines, function (i, line) { + self.pathes[start][i] = []; + var idx = i + offset; + var path = ""; + var stop = 47.5 + 29 * idx; + var sleft = 50 + 100 * startRegionIndex; + var radioStartX = sleft, radioStartY = stop; + var etop = stop; + var endRegionIndex = self.getRegionIndexById(BI.last(line)); + var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line)); + var eleft = 50 + 100 * endRegionIndex; + if (BI.contains(self.start, start)) { + radioStartX = sleft - 50; + path += "M" + (sleft - 50) + "," + stop; + self.pathes[start][i].push({ + x: sleft - 50, + y: stop + }) + } else if (idx === 0) { + radioStartX = sleft + 50; + path += "M" + sleft + "," + stop; + self.pathes[start][i].push({ + x: sleft, + y: stop + }) + } else { + radioStartX = sleft + 50; + path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop; + self.pathes[start][i].push({ + x: sleft, + y: 47.5 + }); + self.pathes[start][i].push({ + x: sleft + 50, + y: 47.5 + }); + self.pathes[start][i].push({ + x: sleft + 50, + y: stop + }); + } + if (idx > 0) { + var endY = endOffset * 29 + 47.5; + path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY; + self.pathes[start][i].push({ + x: eleft - 50, + y: etop + }); + self.pathes[start][i].push({ + x: eleft - 50, + y: endY + }); + self.pathes[start][i].push({ + x: eleft, + y: endY + }); + } else { + path += "L" + eleft + "," + etop; + self.pathes[start][i].push({ + x: eleft, + y: etop + }); + } + + var graph = self.svg.path(path) + .attr({ + stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor, + 'stroke-dasharray': '-' + }); + self.lines[start].push(graph); + if (lines.length > 1) { + self.lines[start][0].toFront(); + } + //第一个元素无论有多少个都要显示radio + if (BI.contains(self.start, start)) { + self.lines[self.regions[0].getValueByIndex(0)][0].toFront(); + } + if (lines.length > 1 || BI.contains(self.start, start)) { + self._drawRadio(start, offset, i, radioStartX, radioStartY); + } + }); + }, + + _drawLines: function (routes) { + var self = this; + this.lines = {}; + this.pathes = {}; + this.radios = {}; + this.regionIndexes = {}; + BI.each(routes, function (k, route) { + if (!self.regionIndexes[k]) { + self.regionIndexes[k] = []; + } + BI.each(route, function (i, rs) { + BI.each(rs, function (j, id) { + var regionIndex = self.getRegionIndexById(id); + if (!BI.contains(self.regionIndexes[k], regionIndex)) { + self.regionIndexes[k].push(regionIndex); + } + }); + }) + }); + BI.each(routes, function (k, route) { + self._drawLine(k, route); + }); + }, + + _pushNodes: function (nodes) { + var self = this; + var indexes = []; + for (var i = 0; i < nodes.length; i++) { + var id = nodes[i]; + var index = self.getRegionIndexById(id); + indexes.push(index); + var region = self.regions[index]; + if (i === nodes.length - 1) { + if (!region.hasItem(id)) { + region.addItem(id, self.texts[id]); + } + break; + } + if (i > 0 || BI.contains(self.start, id)) { + region.addItem(id, self.texts[id]); + } + } + for (var i = BI.first(indexes); i < BI.last(indexes); i++) { + if (!BI.contains(indexes, i)) { + self.regions[i].addItem(""); + } + } + }, + + _createNodes: function () { + var self = this, o = this.options; + this.store = {}; + this.texts = {}; + this.start = []; + this.end = []; + BI.each(o.items, function (i, item) { + self.start.push(BI.first(item).value); + self.end.push(BI.last(item).value); + }); + this.start = BI.uniq(this.start); + this.end = BI.uniq(this.end); + var regions = []; + var tree = new BI.Tree(); + var branches = {}, max = 0; + BI.each(o.items, function (i, items) { + BI.each(items, function (j, item) { + if (!BI.has(branches, item.value)) { + branches[item.value] = 0; + } + branches[item.value]++; + max = Math.max(max, branches[item.value]); + var prev = {}; + if (j > 0) { + prev = items[j - 1]; + } + var parent = self.store[prev.value || ""]; + var node = self.store[item.value] || new BI.Node(item.value); + node.set(item); + self.store[item.value] = node; + self.texts[item.value] = item.text; + self.texts[item.region] = item.regionText; + parent = BI.isNull(parent) ? tree.getRoot() : parent; + if (parent.getChildIndex(item.value) === -1) { + tree.addNode(parent, node); + } + }) + }); + + //算出区域列表 + tree.traverse(function (node) { + BI.each(node.getChildren(), function (i, child) { + if (BI.contains(regions, child.get("region"))) { + var index1 = BI.indexOf(regions, node.get("region")); + var index2 = BI.indexOf(regions, child.get("region")); + //交换区域 + if (index1 > index2) { + var t = regions[index2]; + for (var j = index2; j < index1; j++) { + regions[j] = regions[j + 1]; + } + regions[index1] = t; + } + } else { + regions.push(child.get("region")); + } + }); + }); + this._createRegions(regions); + + //算出节点 + BI.each(branches, function (k, branch) { + if (branch < max) { + delete branches[k]; + } + }); + + //过滤节点 + var nodes = []; + var n = tree.getRoot(); + while (n && n.getChildrenLength() === 1) { + if (BI.has(branches, n.getChildren()[0].id)) { + delete branches[n.getChildren()[0].id]; + n = n.getChildren()[0]; + } else { + n = null; + } + } + tree.traverse(function (node) { + if (BI.has(branches, node.id)) { + nodes.push(node.id); + delete branches[node.id]; + } + }); + + //填充节点 + var routes = {}; + var s, e; + for (var i = 0, len = nodes.length; i < len + 1; i++) { + if (len === 0) { + s = []; + BI.each(this.start, function (i, id) { + s.push(tree.search(id)); + }); + e = []; + BI.each(this.end, function (i, id) { + e.push(tree.search(id)); + }); + } else if (i === len) { + s = e; + e = []; + BI.each(this.end, function (i, id) { + e.push(tree.search(id)); + }); + } else if (i === 0) { + s = []; + BI.each(this.start, function (i, id) { + s.push(tree.search(id)); + }); + e = [tree.search(nodes[i])]; + } else { + s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])]; + e = [tree.search(s[0], nodes[i])]; + } + BI.each(s, function (i, n) { + tree._recursion(n, [n.id], function (node, route) { + if (BI.contains(e, node)) { + if (!routes[n.id]) { + routes[n.id] = []; + } + routes[n.id].push(route); + self._pushNodes(route); + if (e.length <= 1) { + return true; + } + } + }) + }); + } + this.routes = routes; + this._drawLines(routes); + }, + + _unselectAllPath: function () { + var self = this; + BI.each(this.radios, function (idx, rad) { + BI.each(rad, function (i, r) { + r.setSelected(false); + }); + }); + BI.each(this.lines, function (idx, line) { + BI.each(line, function (i, li) { + li.attr("stroke", self._const.lineColor); + }); + }); + BI.each(this.regions, function (idx, region) { + region.reset(); + }); + }, + + populate: function (items) { + this.options.items = items || []; + var self = this; + this.empty(); + if (this.options.items.length <= 0) { + return; + } + this.svg = BI.createWidget({ + type: "bi.svg" + }); + this._createNodes(); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [{ + el: this.svg, + top: 0, + left: 0, + right: 0, + bottom: 0 + }] + }); + }, + + setValue: function (v) { + this._unselectAllPath(); + var nodes = BI.keys(this.routes), self = this; + var result = [], array = []; + BI.each(v, function (i, val) { + if (BI.contains(nodes, val)) { + if (array.length > 0) { + array.push(val); + result.push(array); + array = []; + } + } + array.push(val); + }); + if (array.length > 0) { + result.push(array); + } + //画这n条路径 + BI.each(result, function (idx, path) { + var start = path[0]; + var index = BI.findIndex(self.routes[start], function (idx, p) { + if (BI.isEqual(path, p)) { + return true; + } + }); + if (index >= 0) { + var startRegionIndex = self.getRegionIndexById(start); + var offset = self.regions[startRegionIndex].getIndexByValue(start); + self._drawPath(start, offset, index); + } + }); + }, + + getValue: function () { + var path = []; + BI.each(this.regions, function (i, region) { + var val = region.getValue(); + if (BI.isKey(val)) { + path.push(val); + } + }); + return path; + } +}); +BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE"; +BI.shortcut("bi.path_chooser", BI.PathChooser);/** + * 路径选择区域 + * + * Created by GUY on 2015/12/4. + * @class BI.PathRegion + * @extends BI.Widget + */ +BI.PathRegion = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-path-region bi-background", + width: 80, + title: "" + }) + }, + + _init: function () { + BI.PathRegion.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.zIndex = 100; + var title = BI.createWidget({ + type: "bi.label", + text: o.title, + title: o.title, + height: 30 + }); + title.element.css("zIndex", this.zIndex--); + this.items = []; + this.vertical = BI.createWidget({ + type: "bi.vertical", + element: this, + bgap: 5, + hgap: 10, + items: [title] + }) + }, + + hasItem: function (val) { + return BI.any(this.items, function (i, item) { + return val === item.getValue(); + }); + }, + + addItem: function (value, text) { + if (BI.isKey(value)) { + var label = BI.createWidget({ + type: "bi.label", + cls: "path-region-label bi-card bi-border bi-list-item-select", + text: text, + value: value, + title: text || value, + height: 22 + }); + } else { + var label = BI.createWidget({ + type: "bi.layout", + height: 24 + }); + } + label.element.css("zIndex", this.zIndex--); + this.items.push(label); + this.vertical.addItem(label); + if (this.items.length === 1) { + this.setSelect(0, value); + } + }, + + reset: function () { + BI.each(this.items, function (i, item) { + item.element.removeClass("active"); + }); + }, + + setSelect: function (index, value) { + this.reset(); + if (this.items.length <= 0) { + return; + } + if (this.items.length === 1) { + this.items[0].element.addClass("active"); + return; + } + if (this.items[index].attr("value") === value) { + this.items[index].element.addClass("active"); + } + }, + + setValue: function (value) { + this.setSelect(this.getIndexByValue(value), value); + }, + + getValueByIndex: function (idx) { + return this.items[idx].attr("value"); + }, + + getIndexByValue: function (value) { + return BI.findIndex(this.items, function (i, item) { + return item.attr("value") === value; + }); + }, + + getValue: function () { + var res; + BI.any(this.items, function (i, item) { + if (item.element.hasClass("active")) { + res = item.getValue(); + return true; + } + }); + return res; + } +}); +BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE"; +BI.shortcut("bi.path_region", BI.PathRegion);/** + * 预览表列 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableCell + * @extends BI.Widget + */ +BI.PreviewTableCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableHeaderCell + * @extends BI.Widget + */ +BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-header-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTable + * @extends BI.Widget + */ +BI.PreviewTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table", + isNeedFreeze: false, + freezeCols: [], + rowSize: null, + columnSize: [], + headerRowSize: 30, + header: [], + items: [] + }); + }, + + _init: function () { + BI.PreviewTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + isNeedResize: false, + + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + rowSize: o.rowSize, + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + + header: BI.map(o.header, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_header_cell" + }, item); + }); + }), + items: BI.map(o.items, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_cell" + }, item); + }); + }) + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._adjustColumns(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._adjustColumns(); + }); + }, + + //是否有自适应调节的列,即列宽为"" + _hasAdaptCol: function (columnSize) { + return BI.any(columnSize, function (i, size) { + return size === ""; + }) + }, + + _isPercentage: function (columnSize) { + return columnSize[0] <= 1; + }, + + _adjustColumns: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + //如果存在百分比的情况 + if (this._isPercentage(o.columnSize)) { + if (this._hasAdaptCol(o.columnSize)) { + var findCols = [], remain = 0; + BI.each(o.columnSize, function (i, size) { + if (size === "") { + findCols.push(i); + } else { + remain += size; + } + }); + remain = 1 - remain; + var average = remain / findCols.length; + BI.each(findCols, function (i, col) { + o.columnSize[col] = average; + }); + } + var isRight = BI.first(o.freezeCols) !== 0; + var freezeSize = [], notFreezeSize = []; + BI.each(o.columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + freezeSize.push(size); + } else { + notFreezeSize.push(size); + } + }); + var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize); + BI.each(freezeSize, function (i, size) { + freezeSize[i] = size / sumFreezeSize; + }); + BI.each(notFreezeSize, function (i, size) { + notFreezeSize[i] = size / sumNotFreezeSize; + }); + this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]); + this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize))); + } + } else { + //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100% + if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) { + this.table.setRegionColumnSize(["100%"]); + } + } + }, + + setColumnSize: function (columnSize) { + return this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + return this.table.setHeaderColumnSize(columnSize); + }, + + setRegionColumnSize: function (columnSize) { + return this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize() + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize() + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + return this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + return this.table.setLeftHorizontalScroll(scrollLeft) + }, + + setRightHorizontalScroll: function (scrollLeft) { + return this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + populate: function (items, header) { + this.table.populate(items, header); + } +}); +BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE"; +BI.shortcut('bi.preview_table', BI.PreviewTable);/** + * 季度下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.QuarterCombo + * @extends BI.Widget + */ +BI.QuarterCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-quarter-combo", + behaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.QuarterCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = ""; + this.trigger = BI.createWidget({ + type: "bi.quarter_trigger" + }); + + this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.QuarterTrigger.EVENT_CHANGE, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.QuarterTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () { + if (self.combo.isViewVisible()) { + return; + } + if (this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getKey()); + } else if (!this.getKey()) { + self.setValue(); + } + self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); + }); + this.popup = BI.createWidget({ + type: "bi.quarter_popup", + behaviors: o.behaviors + }); + + this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + el: this.popup + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue() || ""; + } +}); + +BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.quarter_combo', BI.QuarterCombo);/** + * 季度展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.QuarterPopup + * @extends BI.Trigger + */ +BI.QuarterPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-quarter-popup", + behaviors: {} + }); + }, + + _init: function () { + BI.QuarterPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var items = [{ + text: Date._QN[01], + value: 1 + }, { + text: Date._QN[2], + value: 2 + }, { + text: Date._QN[3], + value: 3 + }, { + text: Date._QN[4], + value: 4 + }]; + items = BI.map(items, function (j, item) { + return BI.extend(item, { + type: "bi.text_item", + cls: "bi-list-item-active", + textAlign: "left", + whiteSpace: "nowrap", + once: false, + forceSelected: true, + height: 25 + }); + }); + + this.quarter = BI.createWidget({ + type: "bi.button_group", + element: this, + behaviors: o.behaviors, + items: BI.createItems(items, {}), + layouts: [{ + type: "bi.vertical" + }] + }); + + this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MonthPopup.EVENT_CHANGE); + } + }) + }, + + getValue: function () { + return this.quarter.getValue()[0]; + }, + + setValue: function (v) { + this.quarter.setValue([v]); + } +}); +BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/** + * 季度trigger + * + * Created by GUY on 2015/8/21. + * @class BI.QuarterTrigger + * @extends BI.Trigger + */ +BI.QuarterTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 30, + textWidth: 40, + errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-quarter-trigger bi-border", + height: 25 + }); + }, + _init: function () { + BI.QuarterTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: c.errorText + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + self.editor.setTitle(value); + } + self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_STOP); + }); + + BI.createWidget({ + element: this, + type: 'bi.htape', + items: [ + { + el: this.editor + }, { + el: { + type: "bi.text_button", + baseCls: "bi-trigger-quarter-text", + text: BI.i18nText("BI-Multi_Date_Quarter"), + width: c.textWidth + }, + width: c.textWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + + setValue: function (v) { + this.editor.setState(v); + this.editor.setValue(v); + this.editor.setTitle(v); + }, + + getKey: function () { + return this.editor.getValue(); + } +}); +BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.QuarterTrigger.EVENT_START = "EVENT_START"; +BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP"; +BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/** + * 关联视图字段Item + * + * Created by GUY on 2015/12/23. + * @class BI.RelationViewItem + * @extends BI.Widget + */ +BI.RelationViewItem = BI.inherit(BI.BasicButton, { + + _defaultConfig: function () { + return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-item bi-list-item-active", + height: 25, + hoverIn: BI.emptyFn, + hoverOut: BI.emptyFn + }); + }, + + _init: function () { + BI.RelationViewItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.element.hover(o.hoverIn, o.hoverOut); + var items = []; + if (o.isPrimary) { + items.push({ + type: "bi.icon", + width: 16, + height: 16, + title: BI.i18nText("BI-Primary_Key") + }); + } + items.push({ + type: "bi.label", + text: o.text, + value: o.value, + height: o.height, + textAlign: "left", + width: o.isPrimary ? 70 : 90 + }); + BI.createWidget({ + type: "bi.vertical_adapt", + element: this, + items: items, + cls: "primary-key-font", + lgap: 5 + }); + }, + + enableHover: function (opt) { + BI.RelationViewRegion.superclass.enableHover.apply(this, [{ + container: "body" + }]); + }, + + setSelected: function (b) { + this.element[b ? "addClass" : "removeClass"]("active"); + } +}); +BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/** + * 关联视图 + * + * Created by GUY on 2015/12/22. + * @class BI.RelationView + * @extends BI.Widget + */ +BI.RelationView = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#c4c6c6", + selectLineColor: "#009de3" + }, + + _defaultConfig: function () { + return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view", + items: [] + }); + }, + + _init: function () { + BI.RelationView.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + _calculateWidths: function () { + var widths = []; + BI.each(this.views, function (i, items) { + BI.each(items, function (j, obj) { + if (!widths[j]) { + widths[j] = BI.MIN; + } + widths[j] = Math.max(widths[j], obj.getWidth()); + }) + }); + return widths; + }, + + _calculateHeights: function () { + var heights = BI.makeArray(BI.size(this.views), BI.MIN); + BI.each(this.views, function (i, items) { + BI.each(items, function (j, obj) { + heights[i] = Math.max(heights[i], obj.getHeight()); + }) + }); + return heights; + }, + + _hoverIn: function (target) { + var self = this, c = this._const; + BI.each(this.relations, function (start, rs) { + BI.each(rs, function (end, relation) { + if (relation[0].primary.value === target || relation[0].foreign.value === target) { + self.lines[start][end].attr("stroke", c.selectLineColor).toFront(); + self.storeViews[start].setValue(relation[0].primary.value); + self.storeViews[end].setValue(relation[0].foreign.value); + } + }); + }); + }, + + _hoverOut: function (target) { + var self = this, c = this._const; + BI.each(this.relations, function (start, rs) { + BI.each(rs, function (end, relation) { + if (relation[0].primary.value === target || relation[0].foreign.value === target) { + self.lines[start][end].attr("stroke", c.lineColor); + self.storeViews[start].setValue([]); + self.storeViews[end].setValue([]); + } + }); + }); + }, + + previewRelationTables: function(relationTables, show) { + if (!show) { + BI.each(this.storeViews, function (i, view) { + view.toggleRegion(true); + view.setPreviewSelected(false); + }); + BI.each(this.lines, function (i, lines) { + BI.each(lines, function (j, line) { + line.show(); + }); + }); + return; + } + BI.each(this.storeViews, function (id, view) { + if (!relationTables.contains(id)) { + view.toggleRegion(false); + } else { + view.setPreviewSelected(true); + } + }); + BI.each(this.lines, function (id, lines) { + BI.each(lines, function (cId, line) { + if (!relationTables.contains(id) || !relationTables.contains(cId)) { + line.hide(); + } + }); + }); + }, + + populate: function (items) { + var self = this, o = this.options, c = this._const; + o.items = items || []; + this.empty(); + this.svg = BI.createWidget({ + type: "bi.svg" + }); + + //算出所有的区域和关联 + var regions = this.regions = {}, relations = this.relations = {}; + BI.each(items, function (i, item) { + var pr = item.primary.region, fr = item.foreign && item.foreign.region; + if (pr && !relations[pr]) { + relations[pr] = {}; + } + if (pr && fr && !relations[pr][fr]) { + relations[pr][fr] = []; + } + if (pr && !regions[pr]) { + regions[pr] = []; + } + if (fr && !regions[fr]) { + regions[fr] = []; + } + if (pr && !BI.deepContains(regions[pr], item.primary)) { + regions[pr].push(item.primary); + } + if (fr && !BI.deepContains(regions[fr], item.foreign)) { + regions[fr].push(item.foreign); + } + pr && fr && relations[pr][fr].push(item); + }); + //求拓扑 + var topology = []; + var rs = BI.clone(regions), store = {}; + while (!BI.isEmpty(rs)) { + var clone = BI.clone(rs); + BI.each(o.items, function (i, item) { + if (!store[item.primary.region]) { + delete clone[item.foreign && item.foreign.region]; + } + }); + topology.push(BI.keys(clone)); + BI.extend(store, clone); + BI.each(clone, function (k, v) { + delete rs[k]; + }); + } + //构建视图 + var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {}; + var verticals = []; + BI.each(topology, function (i, items) { + if (!views[i]) { + views[i] = {}; + } + var horizontal = []; + BI.each(items, function (j, region) { + var items = regions[region]; + views[i][j] = storeViews[region] = BI.createWidget({ + type: "bi.relation_view_region_container", + value: region, + header: items[0].regionTitle, + text: items.length > 0 ? items[0].regionText : "", + handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn, + items: items, + belongPackage: items.length > 0 ? items[0].belongPackage : true + }); + if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) { + views[i][j].doRedMark(items[0].keyword); + } + views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) { + self._hoverIn(v); + }); + views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) { + self._hoverOut(v); + }); + views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) { + self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v); + }); + indexes[region] = {i: i, j: j}; + horizontal.push(views[i][j]); + }); + verticals.push({ + type: "bi.horizontal", + items: horizontal + }) + }); + + //求每一行的高度 + var heights = this._calculateHeights(); + + //求每一列的宽度 + var widths = this._calculateWidths(); + + //求相对宽度和高度 + var offsetWidths = [0], offsetHeights = [0]; + BI.each(heights, function (i, h) { + if (i === 0) { + return; + } + offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1]; + }); + BI.each(widths, function (i, w) { + if (i === 0) { + return; + } + offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1]; + }); + + //画线 + var lines = this.lines = {};//缓存所有的线 + BI.each(relations, function (start, rs) { + BI.each(rs, function (end, relation) { + var startIndex = indexes[start], endIndex = indexes[end]; + var top = 0, right = 1, bottom = 2, left = 3; + var startDirection = bottom, endDirection = top; + // if (startIndex.j > endIndex.j) { + // startDirection = left; + // endDirection = right; + // } else if (startIndex.j < endIndex.j) { + // startDirection = right; + // endDirection = left; + // } else if (startIndex.i < endIndex.i) { + // startDirection = bottom; + // endDirection = top; + // } else if (startIndex.i > endIndex.i) { + // startDirection = top; + // endDirection = bottom; + // } + var draw = function (i, j, direction, isForeign) { + var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; + var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; + var path = "", position; + switch (direction) { + case top: + position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + x + "," + (y - 10); + y -= 10; + break; + case right: + position = views[i][j].getRightPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + (x + 10) + "," + y; + x += 10; + break; + case bottom: + position = views[i][j].getBottomPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + x + "," + (y + 10); + y += 10; + break; + case left: + position = views[i][j].getLeftPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + (x - 10) + "," + y; + x -= 10; + break; + } + return {x: x, y: y, path: path}; + }; + var path = ""; + var si = draw(startIndex.i, startIndex.j, startDirection); + var ei = draw(endIndex.i, endIndex.j, endDirection, true); + path += si.path + ei.path; + if (!lines[start]) { + lines[start] = {}; + } + path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y; + var line = lines[start][end] = self.svg.path(path) + .attr({"stroke": c.lineColor, "stroke-width": "2"}) + .hover(function () { + line.attr("stroke", c.selectLineColor).toFront(); + storeViews[start].setValue(relation[0].primary.value); + storeViews[end].setValue(relation[0].foreign.value); + }, function () { + line.attr("stroke", c.lineColor); + storeViews[start].setValue([]); + storeViews[end].setValue([]); + }); + }); + }); + var container = BI.createWidget(); + BI.createWidget({ + type: "bi.vertical", + element: container, + items: verticals + }); + BI.createWidget({ + type: "bi.absolute", + element: container, + items: [{ + el: this.svg, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }); + + BI.createWidget({ + type: "bi.center_adapt", + scrollable: true, + element: this, + items: [container] + }); + } +}); +BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE"; +BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW"; +BI.shortcut('bi.relation_view', BI.RelationView);/** + * Created by Young's on 2017/3/10. + */ +BI.RelationViewRegionContainer = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-region-container", + width: 150 + }); + }, + + _init: function () { + BI.RelationViewRegionContainer.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.region = BI.createWidget({ + type: "bi.relation_view_region", + value: o.value, + header: o.header, + text: o.text, + handler: o.handler, + items: o.items, + belongPackage: o.belongPackage + }); + this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v); + }); + this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v); + }); + this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v); + }); + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.region], + width: this.region.getWidth(), + height: this.region.getHeight() + }); + }, + + doRedMark: function () { + this.region.doRedMark.apply(this.region, arguments); + }, + + unRedMark: function () { + this.region.unRedMark.apply(this.region, arguments); + }, + + getWidth: function () { + return this.region.getWidth(); + }, + + getHeight: function () { + return this.region.getHeight(); + }, + + //获取上方开始划线的位置 + getTopLeftPosition: function () { + return this.region.getTopLeftPosition(); + }, + + getTopRightPosition: function () { + return this.region.getTopRightPosition(); + }, + + getBottomPosition: function () { + return this.region.getBottomPosition(); + }, + + getLeftPosition: function () { + return this.region.getLeftPosition(); + }, + + getRightPosition: function () { + return this.region.getRightPosition(); + }, + + setValue: function (v) { + this.region.setValue(v); + }, + + toggleRegion: function (v) { + v === true ? this.region.element.fadeIn() : this.region.element.fadeOut(); + }, + + setPreviewSelected: function(v) { + this.region.setPreviewSelected(v); + } +}); +BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; +BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; +BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; +BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/** + * 关联视图 + * + * Created by GUY on 2015/12/23. + * @class BI.RelationViewRegion + * @extends BI.BasicButton + */ +BI.RelationViewRegion = BI.inherit(BI.BasicButton, { + + _defaultConfig: function () { + return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-region cursor-pointer", + width: 150, + text: "", + value: "", + header: "", + items: [], + belongPackage: true + }); + }, + + _init: function () { + BI.RelationViewRegion.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.preview = BI.createWidget({ + type: "bi.icon_button", + cls: "relation-table-preview-font", + width: 25, + height: 25, + stopPropagation: true + }); + this.preview.on(BI.IconButton.EVENT_CHANGE, function () { + self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected()); + }); + + this.title = BI.createWidget({ + type: "bi.label", + height: 25, + width: 70, + text: o.text, + value: o.value, + textAlign: "left" + }); + //title放body上 + if (BI.isKey(o.header)) { + this.title.setTitle(o.header, { + container: "body" + }) + } + + this.button_group = BI.createWidget({ + type: "bi.button_group", + items: this._createItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [{ + type: "bi.vertical", + cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), + items: [{ + type: "bi.vertical_adapt", + cls: "relation-view-region-title bi-border-bottom", + items: [this.preview, this.title] + }, this.button_group] + }], + hgap: 25, + vgap: 20 + }) + }, + + _createItems: function (items) { + var self = this; + return BI.map(items, function (i, item) { + return BI.extend(item, { + type: "bi.relation_view_item", + hoverIn: function () { + self.setValue(item.value); + self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); + }, + hoverOut: function () { + self.setValue([]); + self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value); + } + }) + }); + }, + + doRedMark: function () { + this.title.doRedMark.apply(this.title, arguments); + }, + + unRedMark: function () { + this.title.unRedMark.apply(this.title, arguments); + }, + + getWidth: function () { + return this.options.width; + }, + + getHeight: function () { + return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; + }, + + //获取上方开始划线的位置 + getTopLeftPosition: function () { + return { + x: 25 + 10, + y: 20 + } + }, + + getTopRightPosition: function () { + return { + x: this.getWidth() - 25 - 10, + y: 20 + } + }, + + getBottomPosition: function () { + return { + x: 25 + 10, + y: this.getHeight() - 20 + } + }, + + getLeftPosition: function () { + return { + x: 25, + y: 20 + 10 + } + }, + + getRightPosition: function () { + return { + x: this.getWidth() - 25, + y: 20 + 10 + } + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + setPreviewSelected: function(v) { + this.preview.setSelected(v); + } +}); +BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; +BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; +BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; +BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/** + * 自适应宽度的表格 + * + * Created by GUY on 2016/2/3. + * @class BI.ResponisveTable + * @extends BI.Widget + */ +BI.ResponisveTable = BI.inherit(BI.Widget, { + + _const: { + perColumnSize: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-responsive-table", + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 + return BI.isEqual(row1, row2); + }, + + columnSize: [], + headerRowSize: 25, + footerRowSize: 25, + rowSize: 25, + + regionColumnSize: false, + + header: [], + footer: false, + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.ResponisveTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + footerRowSize: o.footerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + header: o.header, + footer: o.footer, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { + //important:在冻结并自适应列宽的情况下要随时变更表头宽度 + if (o.isNeedResize === true && self._isAdaptiveColumn()) { + self._resizeHeader(); + } + self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + + this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { + self._resizeBody(); + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + _initRegionSize: function () { + var o = this.options; + if (o.isNeedFreeze === true) { + var regionColumnSize = this.table.getRegionColumnSize(); + var maxWidth = this.table.element.width(); + if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) { + var freezeCols = o.freezeCols; + if (freezeCols.length === 0) { + this.table.setRegionColumnSize([0, "fill"]); + } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) { + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } else { + this.table.setRegionColumnSize(["fill", 0]); + } + } + } + }, + + _getBlockSize: function () { + var o = this.options; + var columnSize = this.table.getCalculateColumnSize(); + if (o.isNeedFreeze === true) { + var columnSizeLeft = [], columnSizeRight = []; + BI.each(columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + columnSizeLeft.push(size); + } else { + columnSizeRight.push(size); + } + }); + //因为有边框,所以加上数组长度的参数调整 + var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, + sumRight = BI.sum(columnSizeRight) + columnSizeRight.length; + return { + sumLeft: sumLeft, + sumRight: sumRight, + left: columnSizeLeft, + right: columnSizeRight + } + } + return { + size: columnSize, + sum: BI.sum(columnSize) + columnSize.length + }; + }, + + _isAdaptiveColumn: function (columnSize) { + return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05); + }, + + _resizeHeader: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + //若是当前处于自适应调节阶段 + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.table.setHeaderColumnSize(columnSize); + } else { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + var columnSizeLeft = block.left, columnSizeRight = block.right; + columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft; + columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight; + + var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight); + newLeft[newLeft.length - 1] = ""; + newRight[newRight.length - 1] = ""; + this.table.setColumnSize(newLeft.concat(newRight)); + + block = self._getBlockSize(); + if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) { + columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1] + } + if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) { + columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1] + } + + self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight)); + } + } else { + if (!this._isAdaptiveColumn()) { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sum = block.sum; + var size = block.size; + + size[size.length - 1] += regionColumnSize[0] - sum; + + var newSize = BI.clone(size); + newSize[newSize.length - 1] = ""; + this.table.setColumnSize(newSize); + block = this._getBlockSize(); + + if (size[size.length - 1] < block.size[block.size.length - 1]) { + size[size.length - 1] = block.size[block.size.length - 1] + } + this.table.setColumnSize(size); + } + } + }, + + _resizeBody: function () { + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.setColumnSize(columnSize); + } + }, + + _adjustRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) { + this.table.setRegionColumnSize([sumLeft, "fill"]); + } + this._resizeRegion(); + } + }, + + _resizeRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var maxWidth = this.table.element.width(); + if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) { + var freezeCols = o.freezeCols; + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } + } + }, + + + resize: function () { + this.table.resize(); + this._resizeRegion(); + this._resizeHeader(); + }, + + setColumnSize: function (columnSize) { + this.table.setColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + this.table.setHeaderColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + setRegionColumnSize: function (columnSize) { + this.table.setRegionColumnSize(columnSize); + this._resizeHeader(); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize(); + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize(); + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + attr: function () { + BI.ResponisveTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function (items) { + var self = this, o = this.options; + this.table.populate.apply(this.table, arguments); + if (o.isNeedFreeze === true) { + BI.nextTick(function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + }); + } + } +}); +BI.shortcut('bi.responsive_table', BI.ResponisveTable);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.first_tree_node_checkbox", + stopPropagation: true + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 25, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.last_tree_node_checkbox", + stopPropagation: true + }) + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 25, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.mid_tree_node_checkbox", + stopPropagation: true + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 25, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/** + * @class BI.SelectTreeCombo + * @extends BI.Widget + */ +BI.SelectTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-tree-combo", + height: 30, + text: "", + items: [] + }); + }, + + _init: function () { + BI.SelectTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }); + + this.popup = BI.createWidget({ + type: "bi.select_tree_popup", + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); + + +BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/** + * @class BI.SelectTreeExpander + * @extends BI.Widget + */ +BI.SelectTreeExpander = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-tree-expander", + trigger: "click", + toggle: true, + direction: "bottom", + isDefaultInit: true, + el: {}, + popup: {} + }); + }, + + _init: function () { + BI.SelectTreeExpander.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget(BI.extend({stopPropagation: true}, o.el)); + this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.expander.setValue([]); + } + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.expander = BI.createWidget({ + type: "bi.expander", + element: this, + trigger: o.trigger, + toggle: o.toggle, + direction: o.direction, + isDefaultInit: o.isDefaultInit, + el: this.trigger, + popup: o.popup + }); + this.expander.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + self.trigger.setSelected(false); + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + setValue: function (v) { + if (BI.contains(v, this.trigger.getValue())) { + this.trigger.setSelected(true); + this.expander.setValue([]); + } else { + this.trigger.setSelected(false); + this.expander.setValue(v); + } + }, + + getValue: function () { + if (this.trigger.isSelected()) { + return [this.trigger.getValue()]; + } + return this.expander.getValue(); + }, + + populate: function (items) { + this.expander.populate(items); + } +}); + +BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/** + * @class BI.SelectTreePopup + * @extends BI.Pane + */ + +BI.SelectTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-tree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + items: [] + }); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {layer: layer}; + node.id = node.id || BI.UUID(); + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + self._formatItems(node.children); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.last_tree_leaf_item"; + break; + default : + extend.type = "bi.mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _init: function () { + BI.SelectTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.level_tree', + expander: { + type: "bi.select_tree_expander", + isDefaultInit: true + }, + items: this._formatItems(BI.Tree.transformToTreeFormat(o.items)), + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.SelectTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.select_tree_popup", BI.SelectTreePopup);/** + * + * Created by GUY on 2016/8/10. + * @class BI.SequenceTableDynamicNumber + * @extends BI.SequenceTableTreeNumber + */ +BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-sequence-table-dynamic-number" + }); + }, + + _init: function () { + BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments); + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount(node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + } +}); +BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableListNumber + * @extends BI.Widget + */ +BI.SequenceTableListNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-list-number", + isNeedFreeze: false, + scrollTop: 0, + startSequence: 1,//开始的序号 + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: null, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [], + + pageSize: 20 + }); + }, + + _init: function () { + BI.SequenceTableListNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.start = o.startSequence; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: o.headerRowSize * o.header.length - 2 + }, { + el: {type: "bi.layout"}, + height: 2 + }, { + el: this.scrollContainer + }] + }); + this._populate(); + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = o.headerRowSize * o.header.length - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + this.container.setHeight(o.items.length * o.rowSize); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth()); + var start = Math.floor(scrollTop / o.rowSize); + var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize); + var renderedCells = [], renderedKeys = []; + for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) { + var index = BI.deepIndexOf(this.renderedKeys, this.start + i); + var top = i * o.rowSize; + if (index > -1) { + if (o.rowSize !== this.renderedCells[index]._height) { + this.renderedCells[index]._height = o.rowSize; + this.renderedCells[index].el.setHeight(o.rowSize); + } + if (this.renderedCells[index].top !== top) { + this.renderedCells[index].top = top; + this.renderedCells[index].el.element.css("top", top + "px"); + } + renderedCells.push(this.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + height: o.rowSize, + text: this.start + i, + styleGetter: function (index) { + return function () { + return o.sequenceCellStyleGetter(self.start + i - 1); + } + }(cnt) + })); + renderedCells.push({ + el: child, + left: 0, + top: top, + _height: o.rowSize + }); + } + renderedKeys.push(this.start + i); + } + + //已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]) + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + }, + + _populate: function () { + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + v = v < 1 ? 1 : v; + var o = this.options; + this.start = (v - 1) * o.pageSize + 1; + }, + + _restore: function () { + var o = this.options; + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + } + if (header && header !== this.options.header) { + o.header = header; + } + this._populate(); + } +}); +BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/** + * 带有序号的表格 + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTable + * @extends BI.Widget + */ +BI.SequenceTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table", + el: { + type: "bi.adaptive_table" + }, + + sequence: {}, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [], + + showSequence: false, + startSequence: 1//开始的序号 + }); + }, + + _init: function () { + BI.SequenceTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.sequence = BI.createWidget(o.sequence, { + type: "bi.sequence_table_list_number", + invisible: o.showSequence === false, + startSequence: o.startSequence, + isNeedFreeze: o.isNeedFreeze, + header: o.header, + items: o.items, + crossHeader: o.crossHeader, + crossItems: o.crossItems, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + width: 60, + height: o.height && o.height - BI.GridTableScrollbar.SIZE, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter + }); + this.table = BI.createWidget(o.el, { + type: "bi.adaptive_table", + width: o.showSequence === true ? o.width - 60 : o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { + if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { + self.sequence.setVerticalScroll(this.getVerticalScroll()); + self.sequence.populate(); + } + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.htape = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.sequence, + left: 0, + top: 0 + }, { + el: this.table, + top: 0, + left: o.showSequence === true ? 60 : 0 + }] + }); + this._populate(); + }, + + _populate: function () { + var o = this.options; + this.sequence.attr({ + items: o.items, + header: o.header, + crossItems: o.crossItems, + crossHeader: o.crossHeader + }); + if (o.showSequence === true) { + this.sequence.setVisible(true); + this.table.element.css("left", "60px"); + this.table.setWidth(o.width - 60); + } else { + this.sequence.setVisible(false); + this.table.element.css("left", "0px"); + this.table.setWidth(o.width); + } + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(this.options.showSequence ? width - 60 : width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + hasLeftHorizontalScroll: function () { + return this.table.hasLeftHorizontalScroll(); + }, + + hasRightHorizontalScroll: function () { + return this.table.hasRightHorizontalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + this.sequence.setVerticalScroll(scrollTop); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setVPage: function (page) { + this.sequence.setVPage && this.sequence.setVPage(page); + }, + + setHPage: function (page) { + this.sequence.setHPage && this.sequence.setHPage(page); + }, + + attr: function () { + BI.SequenceTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + this.sequence.attr.apply(this.sequence, arguments); + }, + + restore: function () { + this.table.restore(); + this.sequence.restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items) { + o.items = items; + } + if (header) { + o.header = header; + } + if (crossItems) { + o.crossItems = crossItems; + } + if (crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + this.table.populate.apply(this.table, arguments); + this.sequence.populate.apply(this.sequence, arguments); + this.sequence.setVerticalScroll(this.table.getVerticalScroll()); + }, + + destroy: function () { + this.table.destroy(); + BI.SequenceTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.sequence_table', BI.SequenceTable);/** + * @class BI.SingleTreeCombo + * @extends BI.Widget + */ +BI.SingleTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-combo", + trigger: {}, + height: 30, + text: "", + items: [] + }); + }, + + _init: function () { + BI.SingleTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget(BI.extend({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }, o.trigger)); + + this.popup = BI.createWidget({ + type: "bi.single_tree_popup", + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments); + }); + + this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); + }); + }, + + populate: function (items) { + this.combo.populate(items); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); + +BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE"; +BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/** + * @class BI.SingleTreePopup + * @extends BI.Pane + */ + +BI.SingleTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + items: [] + }); + }, + + _init: function () { + BI.SingleTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.level_tree', + expander: { + isDefaultInit: true + }, + items: o.items, + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.SingleTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.single_tree_popup", BI.SingleTreePopup);/** + * @class BI.SingleTreeTrigger + * @extends BI.Trigger + */ + +BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-trigger", + height: 30, + text: "", + items: [] + }); + }, + + _init: function () { + BI.SingleTreeTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.select_text_trigger", + element: this, + text: o.text, + items: o.items, + height: o.height + }); + }, + + _checkTitle: function () { + var self = this, val = this.getValue(); + BI.any(this.options.items, function (i, item) { + if (val.contains(item.value)) { + self.trigger.setTitle(item.text || item.value); + return true; + } + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.options.value = v; + this.trigger.setValue(v); + this._checkTitle(); + }, + + getValue: function () { + return this.options.value || []; + }, + + populate: function (items) { + BI.SingleTreeTrigger.superclass.populate.apply(this, arguments); + this.trigger.populate(items); + } + +}); + +BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/** + * 可以单选多选切换的树 + * + * Created by GUY on 2015/12/21. + * @class BI.SwitchTree + * @extends BI.Widget + */ +BI.SwitchTree = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-switch-tree", + items: [] + }); + }, + + _init: function () { + BI.SwitchTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tab = BI.createWidget({ + type: "bi.tab", + element: this, + tab: null, + defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect, + cardCreator: BI.bind(this._createTree, this) + }); + }, + + _createTree: function (type) { + var self = this, o = this.options; + switch (type) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree = BI.createWidget({ + type: "bi.multilayer_single_level_tree", + isDefaultInit: true, + items: BI.deepClone(o.items) + }); + this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.levelTree; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree = BI.createWidget({ + type: "bi.simple_tree", + items: this._removeIsParent(BI.deepClone(o.items)) + }); + this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.tree; + } + }, + + _removeIsParent: function(items) { + BI.each(items, function(i, item) { + BI.isNotNull(item.isParent) && delete item.isParent; + }); + return items; + }, + + switchSelect: function () { + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.setSelect(BI.SwitchTree.SelectType.MultiSelect); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.setSelect(BI.SwitchTree.SelectType.SingleSelect); + break; + } + }, + + setSelect: function (v) { + this.tab.setSelect(v); + }, + + getSelect: function () { + return this.tab.getSelect(); + }, + + setValue: function (v) { + this.storeValue = v; + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree.setValue(v); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree.setValue(v); + break; + } + }, + + getValue: function () { + return this.tab.getValue(); + }, + + populate: function (items) { + this.options.items = items; + if (BI.isNotNull(this.levelTree)) { + this.levelTree.populate(BI.deepClone(items)); + } + if (BI.isNotNull(this.tree)) { + this.tree.populate(this._removeIsParent(BI.deepClone(items))); + } + } +}); +BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; +BI.SwitchTree.SelectType = { + SingleSelect: BI.Selection.Single, + MultiSelect: BI.Selection.Multi +}; +BI.shortcut('bi.switch_tree', BI.SwitchTree); +/** + * 年份下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.YearCombo + * @extends BI.Widget + */ +BI.YearCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-combo", + behaviors: {}, + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.YearCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = ""; + this.trigger = BI.createWidget({ + type: "bi.year_trigger", + min: o.min, + max: o.max + }); + this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.YearTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_STOP, function () { + self.combo.showView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () { + if (self.combo.isViewVisible()) { + return; + } + if (this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getKey()); + } else if (!this.getKey()) { + self.setValue(); + } + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + destroyWhenHide: true, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: { + type: "bi.year_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.YearPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + } + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + var value = self.trigger.getKey(); + if (BI.isNotNull(value)) { + self.popup.setValue(value); + } else if (!value && value !== self.storeValue) { + self.popup.setValue(self.storeValue); + } else { + self.setValue(); + } + self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_combo', BI.YearCombo);/** + * 年份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.YearPopup + * @extends BI.Trigger + */ +BI.YearPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-popup", + behaviors: {}, + min: '1900-01-01', //最小日期 + max: '2099-12-31' //最大日期 + }); + }, + + _createYearCalendar: function (v) { + var o = this.options, y = this._year; + + var calendar = BI.createWidget({ + type: "bi.year_calendar", + behaviors: o.behaviors, + min: o.min, + max: o.max, + logic: { + dynamic: true + }, + year: y + v * 12 + }); + calendar.setValue(this._year); + return calendar; + }, + + _init: function () { + BI.YearPopup.superclass._init.apply(this, arguments); + var self = this; + + this.selectedYear = this._year = new Date().getFullYear(); + + var backBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 25, + height: 25, + value: -1 + }); + + var preBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 25, + height: 25, + value: 1 + }); + + this.navigation = BI.createWidget({ + type: "bi.navigation", + element: this, + single: true, + logic: { + dynamic: true + }, + tab: { + cls: "year-popup-navigation bi-high-light bi-border-top", + height: 25, + items: [backBtn, preBtn] + }, + cardCreator: BI.bind(this._createYearCalendar, this), + + afterCardShow: function () { + this.setValue(self.selectedYear); + var calendar = this.getSelectedCard(); + backBtn.setEnable(!calendar.isFrontYear()); + preBtn.setEnable(!calendar.isFinalYear()); + } + }); + + this.navigation.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedYear = this.getValue(); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear); + }); + }, + + getValue: function () { + return this.selectedYear; + }, + + setValue: function (v) { + var o = this.options; + if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) { + v = new Date().getFullYear(); + this.selectedYear = ""; + this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); + this.navigation.setValue(""); + } else { + this.selectedYear = v; + this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); + this.navigation.setValue(v); + } + } +}); +BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.year_popup", BI.YearPopup);/** + * 年份trigger + * + * Created by GUY on 2015/8/21. + * @class BI.YearTrigger + * @extends BI.Trigger + */ +BI.YearTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 25, + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), + errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-year-trigger bi-border", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.YearTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid); + return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: c.errorText + }) + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.YearTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.YearTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + self.editor.setTitle(value); + } + self.fireEvent(BI.YearTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.YearTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.YearTrigger.EVENT_ERROR); + }); + BI.createWidget({ + element: this, + type: 'bi.htape', + items: [ + { + el: this.editor + }, { + el: { + type: "bi.text_button", + baseCls: "bi-trigger-year-text", + text: BI.i18nText("BI-Multi_Date_Year"), + width: c.triggerWidth + }, + width: c.triggerWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + setValue: function (v) { + this.editor.setState(v); + this.editor.setValue(v); + this.editor.setTitle(v); + }, + getKey: function () { + return this.editor.getValue() | 0; + } +}); +BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.YearTrigger.EVENT_START = "EVENT_START"; +BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearTrigger.EVENT_STOP = "EVENT_STOP"; +BI.shortcut("bi.year_trigger", BI.YearTrigger);/** + * 年份 + 月份下拉框 + * + * @class BI.YearMonthCombo + * @extends BI.Widget + */ +BI.YearMonthCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-month-combo", + yearBehaviors: {}, + monthBehaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.YearMonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.year = BI.createWidget({ + type: "bi.year_combo", + behaviors: o.yearBehaviors + }); + + this.month = BI.createWidget({ + type: "bi.month_combo", + behaviors: o.monthBehaviors + }); + + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); + }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); + }); + this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.center", + element: this, + hgap: 5, + items: [this.year, this.month] + }); + + }, + + setValue: function (v) { + v = v || {}; + this.month.setValue(v.month); + this.year.setValue(v.year); + }, + + getValue: function () { + return { + year: this.year.getValue(), + month: this.month.getValue() + }; + } +}); +BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/** + * 年份 + 月份下拉框 + * + * @class BI.YearQuarterCombo + * @extends BI.Widget + */ +BI.YearQuarterCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-quarter-combo", + yearBehaviors: {}, + quarterBehaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.YearQuarterCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.year = BI.createWidget({ + type: "bi.year_combo", + behaviors: o.yearBehaviors + }); + + this.quarter = BI.createWidget({ + type: "bi.quarter_combo", + behaviors: o.quarterBehaviors + }); + + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); + }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); + }); + this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.center", + element: this, + hgap: 5, + items: [this.year, this.quarter] + }); + + }, + + setValue: function (v) { + v = v || {}; + this.quarter.setValue(v.quarter); + this.year.setValue(v.year); + }, + + getValue: function () { + return { + year: this.year.getValue(), + quarter: this.quarter.getValue() + }; + } +}); +BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与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 + }); + } + } +});/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与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) { + this.combo.setValue({ + type: BI.Selection.Multi, + value: v || [] + }); + }, + + getValue: function () { + var val = this.combo.getValue() || {}; + if (val.type === BI.Selection.All) { + return val.assist; + } + return val.value || []; + }, + + populate: function () { + this.combo.populate.apply(this, arguments); + } +}); +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.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);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._getTreeNode(parentValues, k); + var newParents = BI.clone(parentValues); + newParents.push(node.value); + createOneJson(node, node.parent && node.parent.id, 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 = BI.deepClone(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 = parentValues.concat(notSelectedValue); + //存储的值中存在这个值就把它删掉 + //例如选中了中国-江苏-南京, 取消中国或江苏或南京 + if (canFindKey(selectedValues, p)) { + //如果搜索的值在父亲链中 + if (isSearchValueInParent(p)) { + //例如选中了 中国-江苏, 搜索江苏, 取消江苏 + //例如选中了 中国-江苏, 搜索江苏, 取消中国 + self._deleteNode(selectedValues, p); + } else { + var searched = []; + var finded = search(parentValues, notSelectedValue, [], searched); + if (finded && BI.isNotEmptyArray(searched)) { + BI.each(searched, function (i, arr) { + var node = self._getNode(selectedValues, arr); + if (node) { + //例如选中了 中国-江苏-南京,搜索南京,取消中国 + self._deleteNode(selectedValues, arr); + } else { + //例如选中了 中国-江苏,搜索南京,取消中国 + expandSelectedValue(selectedValues, arr, BI.last(arr)); + } + }) + } + } + } + + //存储的值中不存在这个值,但父亲节点是全选的情况 + //例如选中了中国-江苏,取消南京 + //important 选中了中国-江苏,取消了江苏,但是搜索的是南京 + if (isChild(selectedValues, p)) { + var result = [], finded = false; + //如果parentValues中有匹配的值,说明搜索结果不在当前值下 + if (isSearchValueInParent(p)) { + finded = true; + } else { + //从当前值开始搜 + finded = search(parentValues, notSelectedValue, result); + p = parentValues; + } + + if (finded === true) { + //去掉点击的节点之后的结果集 + expandSelectedValue(selectedValues, p, notSelectedValue); + //添加去掉搜索的结果集 + if (result.length > 0) { + BI.each(result, function (i, strs) { + self._buildTree(selectedValues, strs); + }) + } + } + } + + } + + function expandSelectedValue(selectedValues, parents, notSelectedValue) { + var next = selectedValues; + var childrenCount = []; + var path = []; + //去掉点击的节点之后的结果集 + BI.some(parents, function (i, v) { + var t = next[v]; + if (t == null) { + if (i === 0) { + return true; + } + if (BI.isEmpty(next)) { + var split = parents.slice(0, i); + var expanded = self._getChildren(split); + path.push(split); + childrenCount.push(expanded.length); + //如果只有一个值且取消的就是这个值 + if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) { + for (var j = childrenCount.length - 1; j >= 0; j--) { + if (childrenCount[j] === 1) { + self._deleteNode(selectedValues, path[j]); + } else { + break; + } + } + } else { + BI.each(expanded, function (m, child) { + if (i === parents.length - 1 && child.value === notSelectedValue) { + return true; + } + next[child.value] = {}; + }); + } + next = next[v]; + } else { + return true; + // next = {}; + // next[v] = {}; + } + } else { + next = t; + } + }); + } + + function search(parents, current, result, searched) { + var newParents = BI.clone(parents); + newParents.push(current); + if (self._isMatch(parents, current, keyword)) { + searched && searched.push(newParents); + return true; + } + + var children = self._getChildren(newParents); + + var notSearch = []; + var can = false; + + BI.each(children, function (i, child) { + if (search(newParents, child.value, result, searched)) { + 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 isSearchValueInParent(parentValues) { + for (var i = 0, len = parentValues.length; i < len; i++) { + if (self._isMatch(parentValues.slice(0, parentValues.length - 1), parentValues[i], keyword)) { + return true; + } + } + return false; + } + + function canFindKey(selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + t = t[v]; + if (t == null) { + return false; + } + } + return true; + } + + function isChild(selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + if (!BI.has(t, v)) { + return false; + } + t = t[v]; + if (BI.isEmpty(t)) { + return true; + } + } + return false; + } + }, + + _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(parentValues, 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._getTreeNode(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]; + } + }, + + _getNode: function (selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + }, + + _deleteNode: function (selectedValues, values) { + var name = values[values.length - 1]; + var p = values.slice(0, values.length - 1); + var pNode = this._getNode(selectedValues, p); + if (pNode != null && pNode[name]) { + delete pNode[name]; + //递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = this._getNode(selectedValues, p); + if (pNode != null) { + delete pNode[name]; + } + } + } + }, + + _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 (parentValues, value, keyword) { + var node = this._getTreeNode(parentValues, value); + var finded = BI.Func.getSearchResult([node.text || node.value], keyword); + return finded.finded.length > 0 || finded.matched.length > 0; + }, + + _getTreeNode: 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._getTreeNode(parentValues.slice(0, parentValues.length - 1), value); + } else { + var parent = this.tree.getRoot(); + } + return parent.getChildren(); + }, + + _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) { + this.combo.setValue(v); + }, + + getValue: function () { + return this.combo.getValue(); + }, + + populate: function () { + 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(); + } + }, + + setSelectedValue: function (v) { + this.pane.setSelectedValue(v); + }, + + 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.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) + }); + } + } +});/** + * 简单的复选下拉框控件, 适用于数据量少的情况 + * 封装了字段处理逻辑 + * + * 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) { + this.combo.setValue(v); + }, + + getValue: function () { + var val = this.combo.getValue() || {}; + return { + type: val.type, + value: val.value + } + }, + + populate: function () { + this.combo.populate.apply(this, arguments); + } +}); +BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM"; +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"; +>>>>>>> 3903ca444e161ac208f69ba22c0a3136d7a0fa81 BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane); \ No newline at end of file diff --git a/demo/config.js b/demo/config.js index e1c8645ca..daa3bf380 100644 --- a/demo/config.js +++ b/demo/config.js @@ -8,6 +8,21 @@ Demo.CONSTANTS = { title: v } }), - TREEITEMS: [{"pId":"0","id":"0_0","text":"( 共25个 )","value":"","open":true},{"pId":"0_0","id":"0_0_0","text":"安徽省( 共1个 )","value":"安徽省","open":true},{"pId":"0_0_0","id":"0_0_0_0","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_0","id":"0_0_1","text":"北京市( 共6个 )","value":"北京市","open":true},{"pId":"0_0_1","id":"0_0_1_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_0_1","id":"0_0_1_1","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_0_1","id":"0_0_1_2","text":"东城区","value":"东城区","open":true},{"pId":"0_0_1","id":"0_0_1_3","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_0_1","id":"0_0_1_4","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_0_1","id":"0_0_1_5","text":"石景山区","value":"石景山区","open":true},{"pId":"0_0","id":"0_0_2","text":"福建省( 共2个 )","value":"福建省","open":true},{"pId":"0_0_2","id":"0_0_2_0","text":"莆田市","value":"莆田市","open":true},{"pId":"0_0_2","id":"0_0_2_1","text":"泉州市","value":"泉州市","open":true},{"pId":"0_0","id":"0_0_3","text":"甘肃省( 共1个 )","value":"甘肃省","open":true},{"pId":"0_0_3","id":"0_0_3_0","text":"兰州市","value":"兰州市","open":true},{"pId":"0_0","id":"0_0_4","text":"广东省( 共5个 )","value":"广东省","open":true},{"pId":"0_0_4","id":"0_0_4_0","text":"东莞市","value":"东莞市","open":true},{"pId":"0_0_4","id":"0_0_4_1","text":"广州市","value":"广州市","open":true},{"pId":"0_0_4","id":"0_0_4_2","text":"惠州市","value":"惠州市","open":true},{"pId":"0_0_4","id":"0_0_4_3","text":"深圳市","value":"深圳市","open":true},{"pId":"0_0_4","id":"0_0_4_4","text":"珠海市","value":"珠海市","open":true},{"pId":"0_0","id":"0_0_5","text":"广西壮族自治区( 共1个 )","value":"广西壮族自治区","open":true},{"pId":"0_0_5","id":"0_0_5_0","text":"南宁市","value":"南宁市","open":true},{"pId":"0_0","id":"0_0_6","text":"河北省( 共2个 )","value":"河北省","open":true},{"pId":"0_0_6","id":"0_0_6_0","text":"保定市","value":"保定市","open":true},{"pId":"0_0_6","id":"0_0_6_1","text":"邢台市","value":"邢台市","open":true},{"pId":"0_0","id":"0_0_7","text":"河南省( 共1个 )","value":"河南省","open":true},{"pId":"0_0_7","id":"0_0_7_0","text":"郑州市","value":"郑州市","open":true},{"pId":"0_0","id":"0_0_8","text":"黑龙江省( 共7个 )","value":"黑龙江省","open":true},{"pId":"0_0_8","id":"0_0_8_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_0_8","id":"0_0_8_1","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_0_8","id":"0_0_8_2","text":"鸡西市","value":"鸡西市","open":true},{"pId":"0_0_8","id":"0_0_8_3","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_0_8","id":"0_0_8_4","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_0_8","id":"0_0_8_5","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_0_8","id":"0_0_8_6","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_0","id":"0_0_9","text":"湖北省( 共1个 )","value":"湖北省","open":true},{"pId":"0_0_9","id":"0_0_9_0","text":"武汉市","value":"武汉市","open":true},{"pId":"0_0","id":"0_0_10","text":"湖南省( 共3个 )","value":"湖南省","open":true},{"pId":"0_0_10","id":"0_0_10_0","text":"常德市","value":"常德市","open":true},{"pId":"0_0_10","id":"0_0_10_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_0_10","id":"0_0_10_2","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_0","id":"0_0_11","text":"吉林省( 共4个 )","value":"吉林省","open":true},{"pId":"0_0_11","id":"0_0_11_0","text":"白山市","value":"白山市","open":true},{"pId":"0_0_11","id":"0_0_11_1","text":"长春市","value":"长春市","open":true},{"pId":"0_0_11","id":"0_0_11_2","text":"松原市","value":"松原市","open":true},{"pId":"0_0_11","id":"0_0_11_3","text":"通化市","value":"通化市","open":true},{"pId":"0_0","id":"0_0_12","text":"江苏省( 共8个 )","value":"江苏省","open":true},{"pId":"0_0_12","id":"0_0_12_0","text":"常州市","value":"常州市","open":true},{"pId":"0_0_12","id":"0_0_12_1","text":"南京市","value":"南京市","open":true},{"pId":"0_0_12","id":"0_0_12_2","text":"南通市","value":"南通市","open":true},{"pId":"0_0_12","id":"0_0_12_3","text":"苏州市","value":"苏州市","open":true},{"pId":"0_0_12","id":"0_0_12_4","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_0_12","id":"0_0_12_5","text":"泰州市","value":"泰州市","open":true},{"pId":"0_0_12","id":"0_0_12_6","text":"无锡市","value":"无锡市","open":true},{"pId":"0_0_12","id":"0_0_12_7","text":"盐城市","value":"盐城市","open":true},{"pId":"0_0","id":"0_0_13","text":"辽宁省( 共11个 )","value":"辽宁省","open":true},{"pId":"0_0_13","id":"0_0_13_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_0_13","id":"0_0_13_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_0_13","id":"0_0_13_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_0_13","id":"0_0_13_3","text":"大连市","value":"大连市","open":true},{"pId":"0_0_13","id":"0_0_13_4","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_0_13","id":"0_0_13_5","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_0_13","id":"0_0_13_6","text":"锦州市","value":"锦州市","open":true},{"pId":"0_0_13","id":"0_0_13_7","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_0_13","id":"0_0_13_8","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_0_13","id":"0_0_13_9","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_0_13","id":"0_0_13_10","text":"营口市","value":"营口市","open":true},{"pId":"0_0","id":"0_0_14","text":"内蒙古( 共1个 )","value":"内蒙古","open":true},{"pId":"0_0_14","id":"0_0_14_0","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_0","id":"0_0_15","text":"宁夏回族自治区( 共1个 )","value":"宁夏回族自治区","open":true},{"pId":"0_0_15","id":"0_0_15_0","text":"银川市","value":"银川市","open":true},{"pId":"0_0","id":"0_0_16","text":"山东省( 共7个 )","value":"山东省","open":true},{"pId":"0_0_16","id":"0_0_16_0","text":"济南市","value":"济南市","open":true},{"pId":"0_0_16","id":"0_0_16_1","text":"济宁市","value":"济宁市","open":true},{"pId":"0_0_16","id":"0_0_16_2","text":"聊城市","value":"聊城市","open":true},{"pId":"0_0_16","id":"0_0_16_3","text":"临沂市","value":"临沂市","open":true},{"pId":"0_0_16","id":"0_0_16_4","text":"青岛市","value":"青岛市","open":true},{"pId":"0_0_16","id":"0_0_16_5","text":"烟台市","value":"烟台市","open":true},{"pId":"0_0_16","id":"0_0_16_6","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_0","id":"0_0_17","text":"山西省( 共1个 )","value":"山西省","open":true},{"pId":"0_0_17","id":"0_0_17_0","text":"太原市","value":"太原市","open":true},{"pId":"0_0","id":"0_0_18","text":"陕西省( 共1个 )","value":"陕西省","open":true},{"pId":"0_0_18","id":"0_0_18_0","text":"西安市","value":"西安市","open":true},{"pId":"0_0","id":"0_0_19","text":"上海市( 共1个 )","value":"上海市","open":true},{"pId":"0_0_19","id":"0_0_19_0","text":"上海市区","value":"上海市区","open":true},{"pId":"0_0","id":"0_0_20","text":"四川省( 共1个 )","value":"四川省","open":true},{"pId":"0_0_20","id":"0_0_20_0","text":"成都市","value":"成都市","open":true},{"pId":"0_0","id":"0_0_21","text":"新疆维吾尔族自治区( 共2个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_0_21","id":"0_0_21_0","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_0_21","id":"0_0_21_1","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_0","id":"0_0_22","text":"云南省( 共1个 )","value":"云南省","open":true},{"pId":"0_0_22","id":"0_0_22_0","text":"昆明市","value":"昆明市","open":true},{"pId":"0_0","id":"0_0_23","text":"浙江省( 共5个 )","value":"浙江省","open":true},{"pId":"0_0_23","id":"0_0_23_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_0_23","id":"0_0_23_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_0_23","id":"0_0_23_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_0_23","id":"0_0_23_3","text":"宁波市","value":"宁波市","open":true},{"pId":"0_0_23","id":"0_0_23_4","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_0","id":"0_0_24","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_0_24","id":"0_0_24_0","text":"重庆市区","value":"重庆市区","open":true},{"pId":"0","id":"0_1","text":"中国( 共34个 )","value":"中国","open":true},{"pId":"0_1","id":"0_1_0","text":"安徽省( 共19个 )","value":"安徽省","open":true},{"pId":"0_1_0","id":"0_1_0_0","text":"安庆市","value":"安庆市","open":true},{"pId":"0_1_0","id":"0_1_0_1","text":"蚌埠市","value":"蚌埠市","open":true},{"pId":"0_1_0","id":"0_1_0_2","text":"亳州市","value":"亳州市","open":true},{"pId":"0_1_0","id":"0_1_0_3","text":"巢湖市","value":"巢湖市","open":true},{"pId":"0_1_0","id":"0_1_0_4","text":"池州市","value":"池州市","open":true},{"pId":"0_1_0","id":"0_1_0_5","text":"滁州市","value":"滁州市","open":true},{"pId":"0_1_0","id":"0_1_0_6","text":"阜阳市","value":"阜阳市","open":true},{"pId":"0_1_0","id":"0_1_0_7","text":"毫州市","value":"毫州市","open":true},{"pId":"0_1_0","id":"0_1_0_8","text":"合肥市","value":"合肥市","open":true},{"pId":"0_1_0","id":"0_1_0_9","text":"淮北市","value":"淮北市","open":true},{"pId":"0_1_0","id":"0_1_0_10","text":"淮南市","value":"淮南市","open":true},{"pId":"0_1_0","id":"0_1_0_11","text":"黄山市","value":"黄山市","open":true},{"pId":"0_1_0","id":"0_1_0_12","text":"六安市","value":"六安市","open":true},{"pId":"0_1_0","id":"0_1_0_13","text":"马鞍山市","value":"马鞍山市","open":true},{"pId":"0_1_0","id":"0_1_0_14","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_0","id":"0_1_0_15","text":"宿州市","value":"宿州市","open":true},{"pId":"0_1_0","id":"0_1_0_16","text":"铜陵市","value":"铜陵市","open":true},{"pId":"0_1_0","id":"0_1_0_17","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_1_0","id":"0_1_0_18","text":"宣城市","value":"宣城市","open":true},{"pId":"0_1","id":"0_1_1","text":"澳门特别行政区( 共1个 )","value":"澳门特别行政区","open":true},{"pId":"0_1_1","id":"0_1_1_0","text":"澳门","value":"澳门","open":true},{"pId":"0_1","id":"0_1_2","text":"北京市( 共17个 )","value":"北京市","open":true},{"pId":"0_1_2","id":"0_1_2_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_1_2","id":"0_1_2_1","text":"昌平区","value":"昌平区","open":true},{"pId":"0_1_2","id":"0_1_2_2","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_1_2","id":"0_1_2_3","text":"大兴区","value":"大兴区","open":true},{"pId":"0_1_2","id":"0_1_2_4","text":"东城区","value":"东城区","open":true},{"pId":"0_1_2","id":"0_1_2_5","text":"房山区","value":"房山区","open":true},{"pId":"0_1_2","id":"0_1_2_6","text":"丰台区","value":"丰台区","open":true},{"pId":"0_1_2","id":"0_1_2_7","text":"海淀区","value":"海淀区","open":true},{"pId":"0_1_2","id":"0_1_2_8","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_1_2","id":"0_1_2_9","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_1_2","id":"0_1_2_10","text":"门头沟区","value":"门头沟区","open":true},{"pId":"0_1_2","id":"0_1_2_11","text":"平谷区","value":"平谷区","open":true},{"pId":"0_1_2","id":"0_1_2_12","text":"石景山区","value":"石景山区","open":true},{"pId":"0_1_2","id":"0_1_2_13","text":"顺义区","value":"顺义区","open":true},{"pId":"0_1_2","id":"0_1_2_14","text":"通州区","value":"通州区","open":true},{"pId":"0_1_2","id":"0_1_2_15","text":"西城区","value":"西城区","open":true},{"pId":"0_1_2","id":"0_1_2_16","text":"西城区 ","value":"西城区 ","open":true},{"pId":"0_1","id":"0_1_3","text":"福建省( 共9个 )","value":"福建省","open":true},{"pId":"0_1_3","id":"0_1_3_0","text":"福州市","value":"福州市","open":true},{"pId":"0_1_3","id":"0_1_3_1","text":"龙岩市","value":"龙岩市","open":true},{"pId":"0_1_3","id":"0_1_3_2","text":"南平市","value":"南平市","open":true},{"pId":"0_1_3","id":"0_1_3_3","text":"宁德市","value":"宁德市","open":true},{"pId":"0_1_3","id":"0_1_3_4","text":"莆田市","value":"莆田市","open":true},{"pId":"0_1_3","id":"0_1_3_5","text":"泉州市","value":"泉州市","open":true},{"pId":"0_1_3","id":"0_1_3_6","text":"三明市","value":"三明市","open":true},{"pId":"0_1_3","id":"0_1_3_7","text":"厦门市","value":"厦门市","open":true},{"pId":"0_1_3","id":"0_1_3_8","text":"漳州市","value":"漳州市","open":true},{"pId":"0_1","id":"0_1_4","text":"甘肃省( 共12个 )","value":"甘肃省","open":true},{"pId":"0_1_4","id":"0_1_4_0","text":"白银市","value":"白银市","open":true},{"pId":"0_1_4","id":"0_1_4_1","text":"嘉峪关市","value":"嘉峪关市","open":true},{"pId":"0_1_4","id":"0_1_4_2","text":"金昌市","value":"金昌市","open":true},{"pId":"0_1_4","id":"0_1_4_3","text":"酒泉市","value":"酒泉市","open":true},{"pId":"0_1_4","id":"0_1_4_4","text":"兰州市","value":"兰州市","open":true},{"pId":"0_1_4","id":"0_1_4_5","text":"陇南市","value":"陇南市","open":true},{"pId":"0_1_4","id":"0_1_4_6","text":"平凉市","value":"平凉市","open":true},{"pId":"0_1_4","id":"0_1_4_7","text":"庆阳市","value":"庆阳市","open":true},{"pId":"0_1_4","id":"0_1_4_8","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_4","id":"0_1_4_9","text":"天水市","value":"天水市","open":true},{"pId":"0_1_4","id":"0_1_4_10","text":"武威市","value":"武威市","open":true},{"pId":"0_1_4","id":"0_1_4_11","text":"张掖市","value":"张掖市","open":true},{"pId":"0_1","id":"0_1_5","text":"广东省( 共21个 )","value":"广东省","open":true},{"pId":"0_1_5","id":"0_1_5_0","text":"潮州市","value":"潮州市","open":true},{"pId":"0_1_5","id":"0_1_5_1","text":"东莞市","value":"东莞市","open":true},{"pId":"0_1_5","id":"0_1_5_2","text":"佛山市","value":"佛山市","open":true},{"pId":"0_1_5","id":"0_1_5_3","text":"广州市","value":"广州市","open":true},{"pId":"0_1_5","id":"0_1_5_4","text":"河源市","value":"河源市","open":true},{"pId":"0_1_5","id":"0_1_5_5","text":"惠州市","value":"惠州市","open":true},{"pId":"0_1_5","id":"0_1_5_6","text":"江门市","value":"江门市","open":true},{"pId":"0_1_5","id":"0_1_5_7","text":"揭阳市","value":"揭阳市","open":true},{"pId":"0_1_5","id":"0_1_5_8","text":"茂名市","value":"茂名市","open":true},{"pId":"0_1_5","id":"0_1_5_9","text":"梅州市","value":"梅州市","open":true},{"pId":"0_1_5","id":"0_1_5_10","text":"清远市","value":"清远市","open":true},{"pId":"0_1_5","id":"0_1_5_11","text":"汕头市","value":"汕头市","open":true},{"pId":"0_1_5","id":"0_1_5_12","text":"汕尾市","value":"汕尾市","open":true},{"pId":"0_1_5","id":"0_1_5_13","text":"韶关市","value":"韶关市","open":true},{"pId":"0_1_5","id":"0_1_5_14","text":"深圳市","value":"深圳市","open":true},{"pId":"0_1_5","id":"0_1_5_15","text":"阳江市","value":"阳江市","open":true},{"pId":"0_1_5","id":"0_1_5_16","text":"云浮市","value":"云浮市","open":true},{"pId":"0_1_5","id":"0_1_5_17","text":"湛江市","value":"湛江市","open":true},{"pId":"0_1_5","id":"0_1_5_18","text":"肇庆市","value":"肇庆市","open":true},{"pId":"0_1_5","id":"0_1_5_19","text":"中山市","value":"中山市","open":true},{"pId":"0_1_5","id":"0_1_5_20","text":"珠海市","value":"珠海市","open":true},{"pId":"0_1","id":"0_1_6","text":"广西壮族自治区( 共14个 )","value":"广西壮族自治区","open":true},{"pId":"0_1_6","id":"0_1_6_0","text":"百色市","value":"百色市","open":true},{"pId":"0_1_6","id":"0_1_6_1","text":"北海市","value":"北海市","open":true},{"pId":"0_1_6","id":"0_1_6_2","text":"崇左市","value":"崇左市","open":true},{"pId":"0_1_6","id":"0_1_6_3","text":"防城港市","value":"防城港市","open":true},{"pId":"0_1_6","id":"0_1_6_4","text":"桂林市","value":"桂林市","open":true},{"pId":"0_1_6","id":"0_1_6_5","text":"贵港市","value":"贵港市","open":true},{"pId":"0_1_6","id":"0_1_6_6","text":"河池市","value":"河池市","open":true},{"pId":"0_1_6","id":"0_1_6_7","text":"贺州市","value":"贺州市","open":true},{"pId":"0_1_6","id":"0_1_6_8","text":"来宾市","value":"来宾市","open":true},{"pId":"0_1_6","id":"0_1_6_9","text":"柳州市","value":"柳州市","open":true},{"pId":"0_1_6","id":"0_1_6_10","text":"南宁市","value":"南宁市","open":true},{"pId":"0_1_6","id":"0_1_6_11","text":"钦州市","value":"钦州市","open":true},{"pId":"0_1_6","id":"0_1_6_12","text":"梧州市","value":"梧州市","open":true},{"pId":"0_1_6","id":"0_1_6_13","text":"玉林市","value":"玉林市","open":true},{"pId":"0_1","id":"0_1_7","text":"贵州省( 共9个 )","value":"贵州省","open":true},{"pId":"0_1_7","id":"0_1_7_0","text":"安顺市","value":"安顺市","open":true},{"pId":"0_1_7","id":"0_1_7_1","text":"毕节地区","value":"毕节地区","open":true},{"pId":"0_1_7","id":"0_1_7_2","text":"贵阳市","value":"贵阳市","open":true},{"pId":"0_1_7","id":"0_1_7_3","text":"六盘水市","value":"六盘水市","open":true},{"pId":"0_1_7","id":"0_1_7_4","text":"黔东南州","value":"黔东南州","open":true},{"pId":"0_1_7","id":"0_1_7_5","text":"黔南州","value":"黔南州","open":true},{"pId":"0_1_7","id":"0_1_7_6","text":"黔西南市","value":"黔西南市","open":true},{"pId":"0_1_7","id":"0_1_7_7","text":"铜仁地区","value":"铜仁地区","open":true},{"pId":"0_1_7","id":"0_1_7_8","text":"遵义市","value":"遵义市","open":true},{"pId":"0_1","id":"0_1_8","text":"海南省( 共2个 )","value":"海南省","open":true},{"pId":"0_1_8","id":"0_1_8_0","text":"海口市","value":"海口市","open":true},{"pId":"0_1_8","id":"0_1_8_1","text":"三亚市","value":"三亚市","open":true},{"pId":"0_1","id":"0_1_9","text":"河北省( 共12个 )","value":"河北省","open":true},{"pId":"0_1_9","id":"0_1_9_0","text":"保定市","value":"保定市","open":true},{"pId":"0_1_9","id":"0_1_9_1","text":"沧州市","value":"沧州市","open":true},{"pId":"0_1_9","id":"0_1_9_2","text":"承德市","value":"承德市","open":true},{"pId":"0_1_9","id":"0_1_9_3","text":"邯郸市","value":"邯郸市","open":true},{"pId":"0_1_9","id":"0_1_9_4","text":"衡水市","value":"衡水市","open":true},{"pId":"0_1_9","id":"0_1_9_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_9","id":"0_1_9_6","text":"秦皇岛市","value":"秦皇岛市","open":true},{"pId":"0_1_9","id":"0_1_9_7","text":"石家庄市","value":"石家庄市","open":true},{"pId":"0_1_9","id":"0_1_9_8","text":"唐山市","value":"唐山市","open":true},{"pId":"0_1_9","id":"0_1_9_9","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_9","id":"0_1_9_10","text":"邢台市","value":"邢台市","open":true},{"pId":"0_1_9","id":"0_1_9_11","text":"张家口市","value":"张家口市","open":true},{"pId":"0_1","id":"0_1_10","text":"河南省( 共19个 )","value":"河南省","open":true},{"pId":"0_1_10","id":"0_1_10_0","text":"安阳市","value":"安阳市","open":true},{"pId":"0_1_10","id":"0_1_10_1","text":"鹤壁市","value":"鹤壁市","open":true},{"pId":"0_1_10","id":"0_1_10_2","text":"济源市","value":"济源市","open":true},{"pId":"0_1_10","id":"0_1_10_3","text":"焦作市","value":"焦作市","open":true},{"pId":"0_1_10","id":"0_1_10_4","text":"开封市","value":"开封市","open":true},{"pId":"0_1_10","id":"0_1_10_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_10","id":"0_1_10_6","text":"洛阳市","value":"洛阳市","open":true},{"pId":"0_1_10","id":"0_1_10_7","text":"漯河市","value":"漯河市","open":true},{"pId":"0_1_10","id":"0_1_10_8","text":"南阳市","value":"南阳市","open":true},{"pId":"0_1_10","id":"0_1_10_9","text":"平顶山市","value":"平顶山市","open":true},{"pId":"0_1_10","id":"0_1_10_10","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_10","id":"0_1_10_11","text":"三门峡市","value":"三门峡市","open":true},{"pId":"0_1_10","id":"0_1_10_12","text":"商丘市","value":"商丘市","open":true},{"pId":"0_1_10","id":"0_1_10_13","text":"新乡市","value":"新乡市","open":true},{"pId":"0_1_10","id":"0_1_10_14","text":"信阳市","value":"信阳市","open":true},{"pId":"0_1_10","id":"0_1_10_15","text":"许昌市","value":"许昌市","open":true},{"pId":"0_1_10","id":"0_1_10_16","text":"郑州市","value":"郑州市","open":true},{"pId":"0_1_10","id":"0_1_10_17","text":"周口市","value":"周口市","open":true},{"pId":"0_1_10","id":"0_1_10_18","text":"驻马店市","value":"驻马店市","open":true},{"pId":"0_1","id":"0_1_11","text":"黑龙江省( 共13个 )","value":"黑龙江省","open":true},{"pId":"0_1_11","id":"0_1_11_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_11","id":"0_1_11_1","text":"大兴安岭地区","value":"大兴安岭地区","open":true},{"pId":"0_1_11","id":"0_1_11_2","text":"大兴安岭市","value":"大兴安岭市","open":true},{"pId":"0_1_11","id":"0_1_11_3","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_1_11","id":"0_1_11_4","text":"鹤港市","value":"鹤港市","open":true},{"pId":"0_1_11","id":"0_1_11_5","text":"黑河市","value":"黑河市","open":true},{"pId":"0_1_11","id":"0_1_11_6","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_1_11","id":"0_1_11_7","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_1_11","id":"0_1_11_8","text":"七台河市","value":"七台河市","open":true},{"pId":"0_1_11","id":"0_1_11_9","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_1_11","id":"0_1_11_10","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_1_11","id":"0_1_11_11","text":"绥化市","value":"绥化市","open":true},{"pId":"0_1_11","id":"0_1_11_12","text":"伊春市","value":"伊春市","open":true},{"pId":"0_1","id":"0_1_12","text":"湖北省( 共16个 )","value":"湖北省","open":true},{"pId":"0_1_12","id":"0_1_12_0","text":"鄂州市","value":"鄂州市","open":true},{"pId":"0_1_12","id":"0_1_12_1","text":"恩施土家族苗族自治州","value":"恩施土家族苗族自治州","open":true},{"pId":"0_1_12","id":"0_1_12_2","text":"黄冈市","value":"黄冈市","open":true},{"pId":"0_1_12","id":"0_1_12_3","text":"黄石市","value":"黄石市","open":true},{"pId":"0_1_12","id":"0_1_12_4","text":"荆门市","value":"荆门市","open":true},{"pId":"0_1_12","id":"0_1_12_5","text":"荆州市","value":"荆州市","open":true},{"pId":"0_1_12","id":"0_1_12_6","text":"神农架市","value":"神农架市","open":true},{"pId":"0_1_12","id":"0_1_12_7","text":"十堰市","value":"十堰市","open":true},{"pId":"0_1_12","id":"0_1_12_8","text":"随州市","value":"随州市","open":true},{"pId":"0_1_12","id":"0_1_12_9","text":"天门市","value":"天门市","open":true},{"pId":"0_1_12","id":"0_1_12_10","text":"武汉市","value":"武汉市","open":true},{"pId":"0_1_12","id":"0_1_12_11","text":"咸宁市","value":"咸宁市","open":true},{"pId":"0_1_12","id":"0_1_12_12","text":"襄樊市","value":"襄樊市","open":true},{"pId":"0_1_12","id":"0_1_12_13","text":"襄阳市","value":"襄阳市","open":true},{"pId":"0_1_12","id":"0_1_12_14","text":"孝感市","value":"孝感市","open":true},{"pId":"0_1_12","id":"0_1_12_15","text":"宜昌市","value":"宜昌市","open":true},{"pId":"0_1","id":"0_1_13","text":"湖南省( 共15个 )","value":"湖南省","open":true},{"pId":"0_1_13","id":"0_1_13_0","text":"常德市","value":"常德市","open":true},{"pId":"0_1_13","id":"0_1_13_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_1_13","id":"0_1_13_2","text":"郴州市","value":"郴州市","open":true},{"pId":"0_1_13","id":"0_1_13_3","text":"衡阳市","value":"衡阳市","open":true},{"pId":"0_1_13","id":"0_1_13_4","text":"怀化市","value":"怀化市","open":true},{"pId":"0_1_13","id":"0_1_13_5","text":"娄底市","value":"娄底市","open":true},{"pId":"0_1_13","id":"0_1_13_6","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_1_13","id":"0_1_13_7","text":"湘潭市","value":"湘潭市","open":true},{"pId":"0_1_13","id":"0_1_13_8","text":"湘西市","value":"湘西市","open":true},{"pId":"0_1_13","id":"0_1_13_9","text":"湘西土家族苗族自治州","value":"湘西土家族苗族自治州","open":true},{"pId":"0_1_13","id":"0_1_13_10","text":"益阳市","value":"益阳市","open":true},{"pId":"0_1_13","id":"0_1_13_11","text":"永州市","value":"永州市","open":true},{"pId":"0_1_13","id":"0_1_13_12","text":"岳阳市","value":"岳阳市","open":true},{"pId":"0_1_13","id":"0_1_13_13","text":"张家界市","value":"张家界市","open":true},{"pId":"0_1_13","id":"0_1_13_14","text":"株洲市","value":"株洲市","open":true},{"pId":"0_1","id":"0_1_14","text":"吉林省( 共10个 )","value":"吉林省","open":true},{"pId":"0_1_14","id":"0_1_14_0","text":"白城市","value":"白城市","open":true},{"pId":"0_1_14","id":"0_1_14_1","text":"白山市","value":"白山市","open":true},{"pId":"0_1_14","id":"0_1_14_2","text":"长春市","value":"长春市","open":true},{"pId":"0_1_14","id":"0_1_14_3","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_14","id":"0_1_14_4","text":"吉林市","value":"吉林市","open":true},{"pId":"0_1_14","id":"0_1_14_5","text":"辽源市","value":"辽源市","open":true},{"pId":"0_1_14","id":"0_1_14_6","text":"四平市","value":"四平市","open":true},{"pId":"0_1_14","id":"0_1_14_7","text":"松原市","value":"松原市","open":true},{"pId":"0_1_14","id":"0_1_14_8","text":"通化市","value":"通化市","open":true},{"pId":"0_1_14","id":"0_1_14_9","text":"延边朝鲜族自治州","value":"延边朝鲜族自治州","open":true},{"pId":"0_1","id":"0_1_15","text":"江苏省( 共13个 )","value":"江苏省","open":true},{"pId":"0_1_15","id":"0_1_15_0","text":"常州市","value":"常州市","open":true},{"pId":"0_1_15","id":"0_1_15_1","text":"淮安市","value":"淮安市","open":true},{"pId":"0_1_15","id":"0_1_15_2","text":"连云港市","value":"连云港市","open":true},{"pId":"0_1_15","id":"0_1_15_3","text":"南京市","value":"南京市","open":true},{"pId":"0_1_15","id":"0_1_15_4","text":"南通市","value":"南通市","open":true},{"pId":"0_1_15","id":"0_1_15_5","text":"苏州市","value":"苏州市","open":true},{"pId":"0_1_15","id":"0_1_15_6","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_1_15","id":"0_1_15_7","text":"泰州市","value":"泰州市","open":true},{"pId":"0_1_15","id":"0_1_15_8","text":"无锡市","value":"无锡市","open":true},{"pId":"0_1_15","id":"0_1_15_9","text":"徐州市","value":"徐州市","open":true},{"pId":"0_1_15","id":"0_1_15_10","text":"盐城市","value":"盐城市","open":true},{"pId":"0_1_15","id":"0_1_15_11","text":"扬州市","value":"扬州市","open":true},{"pId":"0_1_15","id":"0_1_15_12","text":"镇江市","value":"镇江市","open":true},{"pId":"0_1","id":"0_1_16","text":"江西省( 共10个 )","value":"江西省","open":true},{"pId":"0_1_16","id":"0_1_16_0","text":"抚州市","value":"抚州市","open":true},{"pId":"0_1_16","id":"0_1_16_1","text":"赣州市","value":"赣州市","open":true},{"pId":"0_1_16","id":"0_1_16_2","text":"景德镇市","value":"景德镇市","open":true},{"pId":"0_1_16","id":"0_1_16_3","text":"九江市","value":"九江市","open":true},{"pId":"0_1_16","id":"0_1_16_4","text":"南昌市","value":"南昌市","open":true},{"pId":"0_1_16","id":"0_1_16_5","text":"萍乡市","value":"萍乡市","open":true},{"pId":"0_1_16","id":"0_1_16_6","text":"上饶市","value":"上饶市","open":true},{"pId":"0_1_16","id":"0_1_16_7","text":"新余市","value":"新余市","open":true},{"pId":"0_1_16","id":"0_1_16_8","text":"宜春市","value":"宜春市","open":true},{"pId":"0_1_16","id":"0_1_16_9","text":"鹰潭市","value":"鹰潭市","open":true},{"pId":"0_1","id":"0_1_17","text":"辽宁省( 共14个 )","value":"辽宁省","open":true},{"pId":"0_1_17","id":"0_1_17_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_1_17","id":"0_1_17_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_1_17","id":"0_1_17_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_1_17","id":"0_1_17_3","text":"大连市","value":"大连市","open":true},{"pId":"0_1_17","id":"0_1_17_4","text":"丹东市","value":"丹东市","open":true},{"pId":"0_1_17","id":"0_1_17_5","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_1_17","id":"0_1_17_6","text":"阜新市","value":"阜新市","open":true},{"pId":"0_1_17","id":"0_1_17_7","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_1_17","id":"0_1_17_8","text":"锦州市","value":"锦州市","open":true},{"pId":"0_1_17","id":"0_1_17_9","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_1_17","id":"0_1_17_10","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_1_17","id":"0_1_17_11","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_1_17","id":"0_1_17_12","text":"铁岭市","value":"铁岭市","open":true},{"pId":"0_1_17","id":"0_1_17_13","text":"营口市","value":"营口市","open":true},{"pId":"0_1","id":"0_1_18","text":"内蒙古( 共10个 )","value":"内蒙古","open":true},{"pId":"0_1_18","id":"0_1_18_0","text":"包头市","value":"包头市","open":true},{"pId":"0_1_18","id":"0_1_18_1","text":"赤峰市","value":"赤峰市","open":true},{"pId":"0_1_18","id":"0_1_18_2","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_1_18","id":"0_1_18_3","text":"呼和浩特市","value":"呼和浩特市","open":true},{"pId":"0_1_18","id":"0_1_18_4","text":"呼伦贝尔市","value":"呼伦贝尔市","open":true},{"pId":"0_1_18","id":"0_1_18_5","text":"通辽市","value":"通辽市","open":true},{"pId":"0_1_18","id":"0_1_18_6","text":"乌海市","value":"乌海市","open":true},{"pId":"0_1_18","id":"0_1_18_7","text":"锡林郭勒市","value":"锡林郭勒市","open":true},{"pId":"0_1_18","id":"0_1_18_8","text":"兴安市","value":"兴安市","open":true},{"pId":"0_1_18","id":"0_1_18_9","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_19","text":"宁夏回族自治区( 共5个 )","value":"宁夏回族自治区","open":true},{"pId":"0_1_19","id":"0_1_19_0","text":"固原市","value":"固原市","open":true},{"pId":"0_1_19","id":"0_1_19_1","text":"石嘴山市","value":"石嘴山市","open":true},{"pId":"0_1_19","id":"0_1_19_2","text":"吴忠市","value":"吴忠市","open":true},{"pId":"0_1_19","id":"0_1_19_3","text":"银川市","value":"银川市","open":true},{"pId":"0_1_19","id":"0_1_19_4","text":"中卫市","value":"中卫市","open":true},{"pId":"0_1","id":"0_1_20","text":"青海省( 共4个 )","value":"青海省","open":true},{"pId":"0_1_20","id":"0_1_20_0","text":"海东地区","value":"海东地区","open":true},{"pId":"0_1_20","id":"0_1_20_1","text":"海南藏族自治州","value":"海南藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_2","text":"海西蒙古族藏族自治州","value":"海西蒙古族藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_3","text":"西宁市","value":"西宁市","open":true},{"pId":"0_1","id":"0_1_21","text":"山东省( 共17个 )","value":"山东省","open":true},{"pId":"0_1_21","id":"0_1_21_0","text":"滨州市","value":"滨州市","open":true},{"pId":"0_1_21","id":"0_1_21_1","text":"德州市","value":"德州市","open":true},{"pId":"0_1_21","id":"0_1_21_2","text":"东营市","value":"东营市","open":true},{"pId":"0_1_21","id":"0_1_21_3","text":"菏泽市","value":"菏泽市","open":true},{"pId":"0_1_21","id":"0_1_21_4","text":"济南市","value":"济南市","open":true},{"pId":"0_1_21","id":"0_1_21_5","text":"济宁市","value":"济宁市","open":true},{"pId":"0_1_21","id":"0_1_21_6","text":"莱芜市","value":"莱芜市","open":true},{"pId":"0_1_21","id":"0_1_21_7","text":"聊城市","value":"聊城市","open":true},{"pId":"0_1_21","id":"0_1_21_8","text":"临沂市","value":"临沂市","open":true},{"pId":"0_1_21","id":"0_1_21_9","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_21","id":"0_1_21_10","text":"日照市","value":"日照市","open":true},{"pId":"0_1_21","id":"0_1_21_11","text":"泰安市","value":"泰安市","open":true},{"pId":"0_1_21","id":"0_1_21_12","text":"威海市","value":"威海市","open":true},{"pId":"0_1_21","id":"0_1_21_13","text":"潍坊市","value":"潍坊市","open":true},{"pId":"0_1_21","id":"0_1_21_14","text":"烟台市","value":"烟台市","open":true},{"pId":"0_1_21","id":"0_1_21_15","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_1_21","id":"0_1_21_16","text":"淄博市","value":"淄博市","open":true},{"pId":"0_1","id":"0_1_22","text":"山西省( 共12个 )","value":"山西省","open":true},{"pId":"0_1_22","id":"0_1_22_0","text":"长治市","value":"长治市","open":true},{"pId":"0_1_22","id":"0_1_22_1","text":"大同市","value":"大同市","open":true},{"pId":"0_1_22","id":"0_1_22_2","text":"晋城市","value":"晋城市","open":true},{"pId":"0_1_22","id":"0_1_22_3","text":"晋中市","value":"晋中市","open":true},{"pId":"0_1_22","id":"0_1_22_4","text":"临汾市","value":"临汾市","open":true},{"pId":"0_1_22","id":"0_1_22_5","text":"吕梁市","value":"吕梁市","open":true},{"pId":"0_1_22","id":"0_1_22_6","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_22","id":"0_1_22_7","text":"朔州市","value":"朔州市","open":true},{"pId":"0_1_22","id":"0_1_22_8","text":"太原市","value":"太原市","open":true},{"pId":"0_1_22","id":"0_1_22_9","text":"忻州市","value":"忻州市","open":true},{"pId":"0_1_22","id":"0_1_22_10","text":"阳泉市","value":"阳泉市","open":true},{"pId":"0_1_22","id":"0_1_22_11","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_23","text":"陕西省( 共9个 )","value":"陕西省","open":true},{"pId":"0_1_23","id":"0_1_23_0","text":"安康市","value":"安康市","open":true},{"pId":"0_1_23","id":"0_1_23_1","text":"宝鸡市","value":"宝鸡市","open":true},{"pId":"0_1_23","id":"0_1_23_2","text":"汉中市","value":"汉中市","open":true},{"pId":"0_1_23","id":"0_1_23_3","text":"商洛市","value":"商洛市","open":true},{"pId":"0_1_23","id":"0_1_23_4","text":"渭南市","value":"渭南市","open":true},{"pId":"0_1_23","id":"0_1_23_5","text":"西安市","value":"西安市","open":true},{"pId":"0_1_23","id":"0_1_23_6","text":"咸阳市","value":"咸阳市","open":true},{"pId":"0_1_23","id":"0_1_23_7","text":"延安市","value":"延安市","open":true},{"pId":"0_1_23","id":"0_1_23_8","text":"榆林市","value":"榆林市","open":true},{"pId":"0_1","id":"0_1_24","text":"上海市( 共19个 )","value":"上海市","open":true},{"pId":"0_1_24","id":"0_1_24_0","text":"宝山区","value":"宝山区","open":true},{"pId":"0_1_24","id":"0_1_24_1","text":"长宁区","value":"长宁区","open":true},{"pId":"0_1_24","id":"0_1_24_2","text":"崇明县","value":"崇明县","open":true},{"pId":"0_1_24","id":"0_1_24_3","text":"奉贤区","value":"奉贤区","open":true},{"pId":"0_1_24","id":"0_1_24_4","text":"虹口区","value":"虹口区","open":true},{"pId":"0_1_24","id":"0_1_24_5","text":"黄浦区","value":"黄浦区","open":true},{"pId":"0_1_24","id":"0_1_24_6","text":"嘉定区","value":"嘉定区","open":true},{"pId":"0_1_24","id":"0_1_24_7","text":"金山区","value":"金山区","open":true},{"pId":"0_1_24","id":"0_1_24_8","text":"静安区","value":"静安区","open":true},{"pId":"0_1_24","id":"0_1_24_9","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_24","id":"0_1_24_10","text":"闵行区","value":"闵行区","open":true},{"pId":"0_1_24","id":"0_1_24_11","text":"普陀区","value":"普陀区","open":true},{"pId":"0_1_24","id":"0_1_24_12","text":"浦东新区","value":"浦东新区","open":true},{"pId":"0_1_24","id":"0_1_24_13","text":"青浦区","value":"青浦区","open":true},{"pId":"0_1_24","id":"0_1_24_14","text":"上海市区","value":"上海市区","open":true},{"pId":"0_1_24","id":"0_1_24_15","text":"松江区","value":"松江区","open":true},{"pId":"0_1_24","id":"0_1_24_16","text":"徐汇区","value":"徐汇区","open":true},{"pId":"0_1_24","id":"0_1_24_17","text":"杨浦区","value":"杨浦区","open":true},{"pId":"0_1_24","id":"0_1_24_18","text":"闸北区","value":"闸北区","open":true},{"pId":"0_1","id":"0_1_25","text":"四川省( 共21个 )","value":"四川省","open":true},{"pId":"0_1_25","id":"0_1_25_0","text":"阿坝藏族羌族自治州","value":"阿坝藏族羌族自治州","open":true},{"pId":"0_1_25","id":"0_1_25_1","text":"巴中市","value":"巴中市","open":true},{"pId":"0_1_25","id":"0_1_25_2","text":"成都市","value":"成都市","open":true},{"pId":"0_1_25","id":"0_1_25_3","text":"达州市","value":"达州市","open":true},{"pId":"0_1_25","id":"0_1_25_4","text":"德阳市","value":"德阳市","open":true},{"pId":"0_1_25","id":"0_1_25_5","text":"甘孜市","value":"甘孜市","open":true},{"pId":"0_1_25","id":"0_1_25_6","text":"广安市","value":"广安市","open":true},{"pId":"0_1_25","id":"0_1_25_7","text":"广元市","value":"广元市","open":true},{"pId":"0_1_25","id":"0_1_25_8","text":"乐山市","value":"乐山市","open":true},{"pId":"0_1_25","id":"0_1_25_9","text":"凉山市","value":"凉山市","open":true},{"pId":"0_1_25","id":"0_1_25_10","text":"泸州市","value":"泸州市","open":true},{"pId":"0_1_25","id":"0_1_25_11","text":"眉山市","value":"眉山市","open":true},{"pId":"0_1_25","id":"0_1_25_12","text":"绵阳市","value":"绵阳市","open":true},{"pId":"0_1_25","id":"0_1_25_13","text":"南充市","value":"南充市","open":true},{"pId":"0_1_25","id":"0_1_25_14","text":"内江市","value":"内江市","open":true},{"pId":"0_1_25","id":"0_1_25_15","text":"攀枝花市","value":"攀枝花市","open":true},{"pId":"0_1_25","id":"0_1_25_16","text":"遂宁市","value":"遂宁市","open":true},{"pId":"0_1_25","id":"0_1_25_17","text":"雅安市","value":"雅安市","open":true},{"pId":"0_1_25","id":"0_1_25_18","text":"宜宾市","value":"宜宾市","open":true},{"pId":"0_1_25","id":"0_1_25_19","text":"资阳市","value":"资阳市","open":true},{"pId":"0_1_25","id":"0_1_25_20","text":"自贡市","value":"自贡市","open":true},{"pId":"0_1","id":"0_1_26","text":"台湾( 共1个 )","value":"台湾","open":true},{"pId":"0_1_26","id":"0_1_26_0","text":"台北市","value":"台北市","open":true},{"pId":"0_1","id":"0_1_27","text":"天津市( 共1个 )","value":"天津市","open":true},{"pId":"0_1_27","id":"0_1_27_0","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1","id":"0_1_28","text":"西藏自治区( 共2个 )","value":"西藏自治区","open":true},{"pId":"0_1_28","id":"0_1_28_0","text":"阿里市","value":"阿里市","open":true},{"pId":"0_1_28","id":"0_1_28_1","text":"日喀则市","value":"日喀则市","open":true},{"pId":"0_1","id":"0_1_29","text":"香港特别行政区( 共1个 )","value":"香港特别行政区","open":true},{"pId":"0_1_29","id":"0_1_29_0","text":"香港","value":"香港","open":true},{"pId":"0_1","id":"0_1_30","text":"新疆维吾尔族自治区( 共11个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_1_30","id":"0_1_30_0","text":"巴音郭楞市","value":"巴音郭楞市","open":true},{"pId":"0_1_30","id":"0_1_30_1","text":"哈密市","value":"哈密市","open":true},{"pId":"0_1_30","id":"0_1_30_2","text":"和田市","value":"和田市","open":true},{"pId":"0_1_30","id":"0_1_30_3","text":"喀什地区","value":"喀什地区","open":true},{"pId":"0_1_30","id":"0_1_30_4","text":"克拉玛依市","value":"克拉玛依市","open":true},{"pId":"0_1_30","id":"0_1_30_5","text":"克孜勒苏柯州","value":"克孜勒苏柯州","open":true},{"pId":"0_1_30","id":"0_1_30_6","text":"石河子市","value":"石河子市","open":true},{"pId":"0_1_30","id":"0_1_30_7","text":"塔城市","value":"塔城市","open":true},{"pId":"0_1_30","id":"0_1_30_8","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_1_30","id":"0_1_30_9","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_1_30","id":"0_1_30_10","text":"伊犁市","value":"伊犁市","open":true},{"pId":"0_1","id":"0_1_31","text":"云南省( 共12个 )","value":"云南省","open":true},{"pId":"0_1_31","id":"0_1_31_0","text":"保山市","value":"保山市","open":true},{"pId":"0_1_31","id":"0_1_31_1","text":"楚雄彝族自治州","value":"楚雄彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_2","text":"大理白族自治州","value":"大理白族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_3","text":"红河哈尼族彝族自治州","value":"红河哈尼族彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_4","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_31","id":"0_1_31_5","text":"丽江市","value":"丽江市","open":true},{"pId":"0_1_31","id":"0_1_31_6","text":"临沧市","value":"临沧市","open":true},{"pId":"0_1_31","id":"0_1_31_7","text":"曲靖市","value":"曲靖市","open":true},{"pId":"0_1_31","id":"0_1_31_8","text":"思茅市","value":"思茅市","open":true},{"pId":"0_1_31","id":"0_1_31_9","text":"文山市","value":"文山市","open":true},{"pId":"0_1_31","id":"0_1_31_10","text":"玉溪市","value":"玉溪市","open":true},{"pId":"0_1_31","id":"0_1_31_11","text":"昭通市","value":"昭通市","open":true},{"pId":"0_1","id":"0_1_32","text":"浙江省( 共12个 )","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_1_32","id":"0_1_32_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_1_32","id":"0_1_32_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_1_32","id":"0_1_32_3","text":"金华市","value":"金华市","open":true},{"pId":"0_1_32","id":"0_1_32_4","text":"丽水市","value":"丽水市","open":true},{"pId":"0_1_32","id":"0_1_32_5","text":"宁波市","value":"宁波市","open":true},{"pId":"0_1_32","id":"0_1_32_6","text":"衢州市","value":"衢州市","open":true},{"pId":"0_1_32","id":"0_1_32_7","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_1_32","id":"0_1_32_8","text":"台州市","value":"台州市","open":true},{"pId":"0_1_32","id":"0_1_32_9","text":"温州市","value":"温州市","open":true},{"pId":"0_1_32","id":"0_1_32_10","text":"浙江省","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_11","text":"舟山市","value":"舟山市","open":true},{"pId":"0_1","id":"0_1_33","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_1_33","id":"0_1_33_0","text":"重庆市区","value":"重庆市区","open":true}] + TREEITEMS: [{"pId":"0","id":"0_0","text":"( 共25个 )","value":"","open":true},{"pId":"0_0","id":"0_0_0","text":"安徽省( 共1个 )","value":"安徽省","open":true},{"pId":"0_0_0","id":"0_0_0_0","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_0","id":"0_0_1","text":"北京市( 共6个 )","value":"北京市","open":true},{"pId":"0_0_1","id":"0_0_1_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_0_1","id":"0_0_1_1","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_0_1","id":"0_0_1_2","text":"东城区","value":"东城区","open":true},{"pId":"0_0_1","id":"0_0_1_3","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_0_1","id":"0_0_1_4","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_0_1","id":"0_0_1_5","text":"石景山区","value":"石景山区","open":true},{"pId":"0_0","id":"0_0_2","text":"福建省( 共2个 )","value":"福建省","open":true},{"pId":"0_0_2","id":"0_0_2_0","text":"莆田市","value":"莆田市","open":true},{"pId":"0_0_2","id":"0_0_2_1","text":"泉州市","value":"泉州市","open":true},{"pId":"0_0","id":"0_0_3","text":"甘肃省( 共1个 )","value":"甘肃省","open":true},{"pId":"0_0_3","id":"0_0_3_0","text":"兰州市","value":"兰州市","open":true},{"pId":"0_0","id":"0_0_4","text":"广东省( 共5个 )","value":"广东省","open":true},{"pId":"0_0_4","id":"0_0_4_0","text":"东莞市","value":"东莞市","open":true},{"pId":"0_0_4","id":"0_0_4_1","text":"广州市","value":"广州市","open":true},{"pId":"0_0_4","id":"0_0_4_2","text":"惠州市","value":"惠州市","open":true},{"pId":"0_0_4","id":"0_0_4_3","text":"深圳市","value":"深圳市","open":true},{"pId":"0_0_4","id":"0_0_4_4","text":"珠海市","value":"珠海市","open":true},{"pId":"0_0","id":"0_0_5","text":"广西壮族自治区( 共1个 )","value":"广西壮族自治区","open":true},{"pId":"0_0_5","id":"0_0_5_0","text":"南宁市","value":"南宁市","open":true},{"pId":"0_0","id":"0_0_6","text":"河北省( 共2个 )","value":"河北省","open":true},{"pId":"0_0_6","id":"0_0_6_0","text":"保定市","value":"保定市","open":true},{"pId":"0_0_6","id":"0_0_6_1","text":"邢台市","value":"邢台市","open":true},{"pId":"0_0","id":"0_0_7","text":"河南省( 共1个 )","value":"河南省","open":true},{"pId":"0_0_7","id":"0_0_7_0","text":"郑州市","value":"郑州市","open":true},{"pId":"0_0","id":"0_0_8","text":"黑龙江省( 共7个 )","value":"黑龙江省","open":true},{"pId":"0_0_8","id":"0_0_8_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_0_8","id":"0_0_8_1","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_0_8","id":"0_0_8_2","text":"鸡西市","value":"鸡西市","open":true},{"pId":"0_0_8","id":"0_0_8_3","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_0_8","id":"0_0_8_4","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_0_8","id":"0_0_8_5","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_0_8","id":"0_0_8_6","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_0","id":"0_0_9","text":"湖北省( 共1个 )","value":"湖北省","open":true},{"pId":"0_0_9","id":"0_0_9_0","text":"武汉市","value":"武汉市","open":true},{"pId":"0_0","id":"0_0_10","text":"湖南省( 共3个 )","value":"湖南省","open":true},{"pId":"0_0_10","id":"0_0_10_0","text":"常德市","value":"常德市","open":true},{"pId":"0_0_10","id":"0_0_10_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_0_10","id":"0_0_10_2","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_0","id":"0_0_11","text":"吉林省( 共4个 )","value":"吉林省","open":true},{"pId":"0_0_11","id":"0_0_11_0","text":"白山市","value":"白山市","open":true},{"pId":"0_0_11","id":"0_0_11_1","text":"长春市","value":"长春市","open":true},{"pId":"0_0_11","id":"0_0_11_2","text":"松原市","value":"松原市","open":true},{"pId":"0_0_11","id":"0_0_11_3","text":"通化市","value":"通化市","open":true},{"pId":"0_0","id":"0_0_12","text":"江苏省( 共8个 )","value":"江苏省","open":true},{"pId":"0_0_12","id":"0_0_12_0","text":"常州市","value":"常州市","open":true},{"pId":"0_0_12","id":"0_0_12_1","text":"南京市","value":"南京市","open":true},{"pId":"0_0_12","id":"0_0_12_2","text":"南通市","value":"南通市","open":true},{"pId":"0_0_12","id":"0_0_12_3","text":"苏州市","value":"苏州市","open":true},{"pId":"0_0_12","id":"0_0_12_4","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_0_12","id":"0_0_12_5","text":"泰州市","value":"泰州市","open":true},{"pId":"0_0_12","id":"0_0_12_6","text":"无锡市","value":"无锡市","open":true},{"pId":"0_0_12","id":"0_0_12_7","text":"盐城市","value":"盐城市","open":true},{"pId":"0_0","id":"0_0_13","text":"辽宁省( 共11个 )","value":"辽宁省","open":true},{"pId":"0_0_13","id":"0_0_13_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_0_13","id":"0_0_13_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_0_13","id":"0_0_13_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_0_13","id":"0_0_13_3","text":"大连市","value":"大连市","open":true},{"pId":"0_0_13","id":"0_0_13_4","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_0_13","id":"0_0_13_5","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_0_13","id":"0_0_13_6","text":"锦州市","value":"锦州市","open":true},{"pId":"0_0_13","id":"0_0_13_7","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_0_13","id":"0_0_13_8","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_0_13","id":"0_0_13_9","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_0_13","id":"0_0_13_10","text":"营口市","value":"营口市","open":true},{"pId":"0_0","id":"0_0_14","text":"内蒙古( 共1个 )","value":"内蒙古","open":true},{"pId":"0_0_14","id":"0_0_14_0","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_0","id":"0_0_15","text":"宁夏回族自治区( 共1个 )","value":"宁夏回族自治区","open":true},{"pId":"0_0_15","id":"0_0_15_0","text":"银川市","value":"银川市","open":true},{"pId":"0_0","id":"0_0_16","text":"山东省( 共7个 )","value":"山东省","open":true},{"pId":"0_0_16","id":"0_0_16_0","text":"济南市","value":"济南市","open":true},{"pId":"0_0_16","id":"0_0_16_1","text":"济宁市","value":"济宁市","open":true},{"pId":"0_0_16","id":"0_0_16_2","text":"聊城市","value":"聊城市","open":true},{"pId":"0_0_16","id":"0_0_16_3","text":"临沂市","value":"临沂市","open":true},{"pId":"0_0_16","id":"0_0_16_4","text":"青岛市","value":"青岛市","open":true},{"pId":"0_0_16","id":"0_0_16_5","text":"烟台市","value":"烟台市","open":true},{"pId":"0_0_16","id":"0_0_16_6","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_0","id":"0_0_17","text":"山西省( 共1个 )","value":"山西省","open":true},{"pId":"0_0_17","id":"0_0_17_0","text":"太原市","value":"太原市","open":true},{"pId":"0_0","id":"0_0_18","text":"陕西省( 共1个 )","value":"陕西省","open":true},{"pId":"0_0_18","id":"0_0_18_0","text":"西安市","value":"西安市","open":true},{"pId":"0_0","id":"0_0_19","text":"上海市( 共1个 )","value":"上海市","open":true},{"pId":"0_0_19","id":"0_0_19_0","text":"上海市区","value":"上海市区","open":true},{"pId":"0_0","id":"0_0_20","text":"四川省( 共1个 )","value":"四川省","open":true},{"pId":"0_0_20","id":"0_0_20_0","text":"成都市","value":"成都市","open":true},{"pId":"0_0","id":"0_0_21","text":"新疆维吾尔族自治区( 共2个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_0_21","id":"0_0_21_0","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_0_21","id":"0_0_21_1","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_0","id":"0_0_22","text":"云南省( 共1个 )","value":"云南省","open":true},{"pId":"0_0_22","id":"0_0_22_0","text":"昆明市","value":"昆明市","open":true},{"pId":"0_0","id":"0_0_23","text":"浙江省( 共5个 )","value":"浙江省","open":true},{"pId":"0_0_23","id":"0_0_23_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_0_23","id":"0_0_23_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_0_23","id":"0_0_23_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_0_23","id":"0_0_23_3","text":"宁波市","value":"宁波市","open":true},{"pId":"0_0_23","id":"0_0_23_4","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_0","id":"0_0_24","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_0_24","id":"0_0_24_0","text":"重庆市区","value":"重庆市区","open":true},{"pId":"0","id":"0_1","text":"中国( 共34个 )","value":"中国","open":true},{"pId":"0_1","id":"0_1_0","text":"安徽省( 共19个 )","value":"安徽省","open":true},{"pId":"0_1_0","id":"0_1_0_0","text":"安庆市","value":"安庆市","open":true},{"pId":"0_1_0","id":"0_1_0_1","text":"蚌埠市","value":"蚌埠市","open":true},{"pId":"0_1_0","id":"0_1_0_2","text":"亳州市","value":"亳州市","open":true},{"pId":"0_1_0","id":"0_1_0_3","text":"巢湖市","value":"巢湖市","open":true},{"pId":"0_1_0","id":"0_1_0_4","text":"池州市","value":"池州市","open":true},{"pId":"0_1_0","id":"0_1_0_5","text":"滁州市","value":"滁州市","open":true},{"pId":"0_1_0","id":"0_1_0_6","text":"阜阳市","value":"阜阳市","open":true},{"pId":"0_1_0","id":"0_1_0_7","text":"毫州市","value":"毫州市","open":true},{"pId":"0_1_0","id":"0_1_0_8","text":"合肥市","value":"合肥市","open":true},{"pId":"0_1_0","id":"0_1_0_9","text":"淮北市","value":"淮北市","open":true},{"pId":"0_1_0","id":"0_1_0_10","text":"淮南市","value":"淮南市","open":true},{"pId":"0_1_0","id":"0_1_0_11","text":"黄山市","value":"黄山市","open":true},{"pId":"0_1_0","id":"0_1_0_12","text":"六安市","value":"六安市","open":true},{"pId":"0_1_0","id":"0_1_0_13","text":"马鞍山市","value":"马鞍山市","open":true},{"pId":"0_1_0","id":"0_1_0_14","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_0","id":"0_1_0_15","text":"宿州市","value":"宿州市","open":true},{"pId":"0_1_0","id":"0_1_0_16","text":"铜陵市","value":"铜陵市","open":true},{"pId":"0_1_0","id":"0_1_0_17","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_1_0","id":"0_1_0_18","text":"宣城市","value":"宣城市","open":true},{"pId":"0_1","id":"0_1_1","text":"澳门特别行政区( 共1个 )","value":"澳门特别行政区","open":true},{"pId":"0_1_1","id":"0_1_1_0","text":"澳门","value":"澳门","open":true},{"pId":"0_1","id":"0_1_2","text":"北京市( 共17个 )","value":"北京市","open":true},{"pId":"0_1_2","id":"0_1_2_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_1_2","id":"0_1_2_1","text":"昌平区","value":"昌平区","open":true},{"pId":"0_1_2","id":"0_1_2_2","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_1_2","id":"0_1_2_3","text":"大兴区","value":"大兴区","open":true},{"pId":"0_1_2","id":"0_1_2_4","text":"东城区","value":"东城区","open":true},{"pId":"0_1_2","id":"0_1_2_5","text":"房山区","value":"房山区","open":true},{"pId":"0_1_2","id":"0_1_2_6","text":"丰台区","value":"丰台区","open":true},{"pId":"0_1_2","id":"0_1_2_7","text":"海淀区","value":"海淀区","open":true},{"pId":"0_1_2","id":"0_1_2_8","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_1_2","id":"0_1_2_9","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_1_2","id":"0_1_2_10","text":"门头沟区","value":"门头沟区","open":true},{"pId":"0_1_2","id":"0_1_2_11","text":"平谷区","value":"平谷区","open":true},{"pId":"0_1_2","id":"0_1_2_12","text":"石景山区","value":"石景山区","open":true},{"pId":"0_1_2","id":"0_1_2_13","text":"顺义区","value":"顺义区","open":true},{"pId":"0_1_2","id":"0_1_2_14","text":"通州区","value":"通州区","open":true},{"pId":"0_1_2","id":"0_1_2_15","text":"西城区","value":"西城区","open":true},{"pId":"0_1_2","id":"0_1_2_16","text":"西城区 ","value":"西城区 ","open":true},{"pId":"0_1","id":"0_1_3","text":"福建省( 共9个 )","value":"福建省","open":true},{"pId":"0_1_3","id":"0_1_3_0","text":"福州市","value":"福州市","open":true},{"pId":"0_1_3","id":"0_1_3_1","text":"龙岩市","value":"龙岩市","open":true},{"pId":"0_1_3","id":"0_1_3_2","text":"南平市","value":"南平市","open":true},{"pId":"0_1_3","id":"0_1_3_3","text":"宁德市","value":"宁德市","open":true},{"pId":"0_1_3","id":"0_1_3_4","text":"莆田市","value":"莆田市","open":true},{"pId":"0_1_3","id":"0_1_3_5","text":"泉州市","value":"泉州市","open":true},{"pId":"0_1_3","id":"0_1_3_6","text":"三明市","value":"三明市","open":true},{"pId":"0_1_3","id":"0_1_3_7","text":"厦门市","value":"厦门市","open":true},{"pId":"0_1_3","id":"0_1_3_8","text":"漳州市","value":"漳州市","open":true},{"pId":"0_1","id":"0_1_4","text":"甘肃省( 共12个 )","value":"甘肃省","open":true},{"pId":"0_1_4","id":"0_1_4_0","text":"白银市","value":"白银市","open":true},{"pId":"0_1_4","id":"0_1_4_1","text":"嘉峪关市","value":"嘉峪关市","open":true},{"pId":"0_1_4","id":"0_1_4_2","text":"金昌市","value":"金昌市","open":true},{"pId":"0_1_4","id":"0_1_4_3","text":"酒泉市","value":"酒泉市","open":true},{"pId":"0_1_4","id":"0_1_4_4","text":"兰州市","value":"兰州市","open":true},{"pId":"0_1_4","id":"0_1_4_5","text":"陇南市","value":"陇南市","open":true},{"pId":"0_1_4","id":"0_1_4_6","text":"平凉市","value":"平凉市","open":true},{"pId":"0_1_4","id":"0_1_4_7","text":"庆阳市","value":"庆阳市","open":true},{"pId":"0_1_4","id":"0_1_4_8","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_4","id":"0_1_4_9","text":"天水市","value":"天水市","open":true},{"pId":"0_1_4","id":"0_1_4_10","text":"武威市","value":"武威市","open":true},{"pId":"0_1_4","id":"0_1_4_11","text":"张掖市","value":"张掖市","open":true},{"pId":"0_1","id":"0_1_5","text":"广东省( 共21个 )","value":"广东省","open":true},{"pId":"0_1_5","id":"0_1_5_0","text":"潮州市","value":"潮州市","open":true},{"pId":"0_1_5","id":"0_1_5_1","text":"东莞市","value":"东莞市","open":true},{"pId":"0_1_5","id":"0_1_5_2","text":"佛山市","value":"佛山市","open":true},{"pId":"0_1_5","id":"0_1_5_3","text":"广州市","value":"广州市","open":true},{"pId":"0_1_5","id":"0_1_5_4","text":"河源市","value":"河源市","open":true},{"pId":"0_1_5","id":"0_1_5_5","text":"惠州市","value":"惠州市","open":true},{"pId":"0_1_5","id":"0_1_5_6","text":"江门市","value":"江门市","open":true},{"pId":"0_1_5","id":"0_1_5_7","text":"揭阳市","value":"揭阳市","open":true},{"pId":"0_1_5","id":"0_1_5_8","text":"茂名市","value":"茂名市","open":true},{"pId":"0_1_5","id":"0_1_5_9","text":"梅州市","value":"梅州市","open":true},{"pId":"0_1_5","id":"0_1_5_10","text":"清远市","value":"清远市","open":true},{"pId":"0_1_5","id":"0_1_5_11","text":"汕头市","value":"汕头市","open":true},{"pId":"0_1_5","id":"0_1_5_12","text":"汕尾市","value":"汕尾市","open":true},{"pId":"0_1_5","id":"0_1_5_13","text":"韶关市","value":"韶关市","open":true},{"pId":"0_1_5","id":"0_1_5_14","text":"深圳市","value":"深圳市","open":true},{"pId":"0_1_5","id":"0_1_5_15","text":"阳江市","value":"阳江市","open":true},{"pId":"0_1_5","id":"0_1_5_16","text":"云浮市","value":"云浮市","open":true},{"pId":"0_1_5","id":"0_1_5_17","text":"湛江市","value":"湛江市","open":true},{"pId":"0_1_5","id":"0_1_5_18","text":"肇庆市","value":"肇庆市","open":true},{"pId":"0_1_5","id":"0_1_5_19","text":"中山市","value":"中山市","open":true},{"pId":"0_1_5","id":"0_1_5_20","text":"珠海市","value":"珠海市","open":true},{"pId":"0_1","id":"0_1_6","text":"广西壮族自治区( 共14个 )","value":"广西壮族自治区","open":true},{"pId":"0_1_6","id":"0_1_6_0","text":"百色市","value":"百色市","open":true},{"pId":"0_1_6","id":"0_1_6_1","text":"北海市","value":"北海市","open":true},{"pId":"0_1_6","id":"0_1_6_2","text":"崇左市","value":"崇左市","open":true},{"pId":"0_1_6","id":"0_1_6_3","text":"防城港市","value":"防城港市","open":true},{"pId":"0_1_6","id":"0_1_6_4","text":"桂林市","value":"桂林市","open":true},{"pId":"0_1_6","id":"0_1_6_5","text":"贵港市","value":"贵港市","open":true},{"pId":"0_1_6","id":"0_1_6_6","text":"河池市","value":"河池市","open":true},{"pId":"0_1_6","id":"0_1_6_7","text":"贺州市","value":"贺州市","open":true},{"pId":"0_1_6","id":"0_1_6_8","text":"来宾市","value":"来宾市","open":true},{"pId":"0_1_6","id":"0_1_6_9","text":"柳州市","value":"柳州市","open":true},{"pId":"0_1_6","id":"0_1_6_10","text":"南宁市","value":"南宁市","open":true},{"pId":"0_1_6","id":"0_1_6_11","text":"钦州市","value":"钦州市","open":true},{"pId":"0_1_6","id":"0_1_6_12","text":"梧州市","value":"梧州市","open":true},{"pId":"0_1_6","id":"0_1_6_13","text":"玉林市","value":"玉林市","open":true},{"pId":"0_1","id":"0_1_7","text":"贵州省( 共9个 )","value":"贵州省","open":true},{"pId":"0_1_7","id":"0_1_7_0","text":"安顺市","value":"安顺市","open":true},{"pId":"0_1_7","id":"0_1_7_1","text":"毕节地区","value":"毕节地区","open":true},{"pId":"0_1_7","id":"0_1_7_2","text":"贵阳市","value":"贵阳市","open":true},{"pId":"0_1_7","id":"0_1_7_3","text":"六盘水市","value":"六盘水市","open":true},{"pId":"0_1_7","id":"0_1_7_4","text":"黔东南州","value":"黔东南州","open":true},{"pId":"0_1_7","id":"0_1_7_5","text":"黔南州","value":"黔南州","open":true},{"pId":"0_1_7","id":"0_1_7_6","text":"黔西南市","value":"黔西南市","open":true},{"pId":"0_1_7","id":"0_1_7_7","text":"铜仁地区","value":"铜仁地区","open":true},{"pId":"0_1_7","id":"0_1_7_8","text":"遵义市","value":"遵义市","open":true},{"pId":"0_1","id":"0_1_8","text":"海南省( 共2个 )","value":"海南省","open":true},{"pId":"0_1_8","id":"0_1_8_0","text":"海口市","value":"海口市","open":true},{"pId":"0_1_8","id":"0_1_8_1","text":"三亚市","value":"三亚市","open":true},{"pId":"0_1","id":"0_1_9","text":"河北省( 共12个 )","value":"河北省","open":true},{"pId":"0_1_9","id":"0_1_9_0","text":"保定市","value":"保定市","open":true},{"pId":"0_1_9","id":"0_1_9_1","text":"沧州市","value":"沧州市","open":true},{"pId":"0_1_9","id":"0_1_9_2","text":"承德市","value":"承德市","open":true},{"pId":"0_1_9","id":"0_1_9_3","text":"邯郸市","value":"邯郸市","open":true},{"pId":"0_1_9","id":"0_1_9_4","text":"衡水市","value":"衡水市","open":true},{"pId":"0_1_9","id":"0_1_9_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_9","id":"0_1_9_6","text":"秦皇岛市","value":"秦皇岛市","open":true},{"pId":"0_1_9","id":"0_1_9_7","text":"石家庄市","value":"石家庄市","open":true},{"pId":"0_1_9","id":"0_1_9_8","text":"唐山市","value":"唐山市","open":true},{"pId":"0_1_9","id":"0_1_9_9","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_9","id":"0_1_9_10","text":"邢台市","value":"邢台市","open":true},{"pId":"0_1_9","id":"0_1_9_11","text":"张家口市","value":"张家口市","open":true},{"pId":"0_1","id":"0_1_10","text":"河南省( 共19个 )","value":"河南省","open":true},{"pId":"0_1_10","id":"0_1_10_0","text":"安阳市","value":"安阳市","open":true},{"pId":"0_1_10","id":"0_1_10_1","text":"鹤壁市","value":"鹤壁市","open":true},{"pId":"0_1_10","id":"0_1_10_2","text":"济源市","value":"济源市","open":true},{"pId":"0_1_10","id":"0_1_10_3","text":"焦作市","value":"焦作市","open":true},{"pId":"0_1_10","id":"0_1_10_4","text":"开封市","value":"开封市","open":true},{"pId":"0_1_10","id":"0_1_10_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_10","id":"0_1_10_6","text":"洛阳市","value":"洛阳市","open":true},{"pId":"0_1_10","id":"0_1_10_7","text":"漯河市","value":"漯河市","open":true},{"pId":"0_1_10","id":"0_1_10_8","text":"南阳市","value":"南阳市","open":true},{"pId":"0_1_10","id":"0_1_10_9","text":"平顶山市","value":"平顶山市","open":true},{"pId":"0_1_10","id":"0_1_10_10","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_10","id":"0_1_10_11","text":"三门峡市","value":"三门峡市","open":true},{"pId":"0_1_10","id":"0_1_10_12","text":"商丘市","value":"商丘市","open":true},{"pId":"0_1_10","id":"0_1_10_13","text":"新乡市","value":"新乡市","open":true},{"pId":"0_1_10","id":"0_1_10_14","text":"信阳市","value":"信阳市","open":true},{"pId":"0_1_10","id":"0_1_10_15","text":"许昌市","value":"许昌市","open":true},{"pId":"0_1_10","id":"0_1_10_16","text":"郑州市","value":"郑州市","open":true},{"pId":"0_1_10","id":"0_1_10_17","text":"周口市","value":"周口市","open":true},{"pId":"0_1_10","id":"0_1_10_18","text":"驻马店市","value":"驻马店市","open":true},{"pId":"0_1","id":"0_1_11","text":"黑龙江省( 共13个 )","value":"黑龙江省","open":true},{"pId":"0_1_11","id":"0_1_11_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_11","id":"0_1_11_1","text":"大兴安岭地区","value":"大兴安岭地区","open":true},{"pId":"0_1_11","id":"0_1_11_2","text":"大兴安岭市","value":"大兴安岭市","open":true},{"pId":"0_1_11","id":"0_1_11_3","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_1_11","id":"0_1_11_4","text":"鹤港市","value":"鹤港市","open":true},{"pId":"0_1_11","id":"0_1_11_5","text":"黑河市","value":"黑河市","open":true},{"pId":"0_1_11","id":"0_1_11_6","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_1_11","id":"0_1_11_7","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_1_11","id":"0_1_11_8","text":"七台河市","value":"七台河市","open":true},{"pId":"0_1_11","id":"0_1_11_9","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_1_11","id":"0_1_11_10","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_1_11","id":"0_1_11_11","text":"绥化市","value":"绥化市","open":true},{"pId":"0_1_11","id":"0_1_11_12","text":"伊春市","value":"伊春市","open":true},{"pId":"0_1","id":"0_1_12","text":"湖北省( 共16个 )","value":"湖北省","open":true},{"pId":"0_1_12","id":"0_1_12_0","text":"鄂州市","value":"鄂州市","open":true},{"pId":"0_1_12","id":"0_1_12_1","text":"恩施土家族苗族自治州","value":"恩施土家族苗族自治州","open":true},{"pId":"0_1_12","id":"0_1_12_2","text":"黄冈市","value":"黄冈市","open":true},{"pId":"0_1_12","id":"0_1_12_3","text":"黄石市","value":"黄石市","open":true},{"pId":"0_1_12","id":"0_1_12_4","text":"荆门市","value":"荆门市","open":true},{"pId":"0_1_12","id":"0_1_12_5","text":"荆州市","value":"荆州市","open":true},{"pId":"0_1_12","id":"0_1_12_6","text":"神农架市","value":"神农架市","open":true},{"pId":"0_1_12","id":"0_1_12_7","text":"十堰市","value":"十堰市","open":true},{"pId":"0_1_12","id":"0_1_12_8","text":"随州市","value":"随州市","open":true},{"pId":"0_1_12","id":"0_1_12_9","text":"天门市","value":"天门市","open":true},{"pId":"0_1_12","id":"0_1_12_10","text":"武汉市","value":"武汉市","open":true},{"pId":"0_1_12","id":"0_1_12_11","text":"咸宁市","value":"咸宁市","open":true},{"pId":"0_1_12","id":"0_1_12_12","text":"襄樊市","value":"襄樊市","open":true},{"pId":"0_1_12","id":"0_1_12_13","text":"襄阳市","value":"襄阳市","open":true},{"pId":"0_1_12","id":"0_1_12_14","text":"孝感市","value":"孝感市","open":true},{"pId":"0_1_12","id":"0_1_12_15","text":"宜昌市","value":"宜昌市","open":true},{"pId":"0_1","id":"0_1_13","text":"湖南省( 共15个 )","value":"湖南省","open":true},{"pId":"0_1_13","id":"0_1_13_0","text":"常德市","value":"常德市","open":true},{"pId":"0_1_13","id":"0_1_13_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_1_13","id":"0_1_13_2","text":"郴州市","value":"郴州市","open":true},{"pId":"0_1_13","id":"0_1_13_3","text":"衡阳市","value":"衡阳市","open":true},{"pId":"0_1_13","id":"0_1_13_4","text":"怀化市","value":"怀化市","open":true},{"pId":"0_1_13","id":"0_1_13_5","text":"娄底市","value":"娄底市","open":true},{"pId":"0_1_13","id":"0_1_13_6","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_1_13","id":"0_1_13_7","text":"湘潭市","value":"湘潭市","open":true},{"pId":"0_1_13","id":"0_1_13_8","text":"湘西市","value":"湘西市","open":true},{"pId":"0_1_13","id":"0_1_13_9","text":"湘西土家族苗族自治州","value":"湘西土家族苗族自治州","open":true},{"pId":"0_1_13","id":"0_1_13_10","text":"益阳市","value":"益阳市","open":true},{"pId":"0_1_13","id":"0_1_13_11","text":"永州市","value":"永州市","open":true},{"pId":"0_1_13","id":"0_1_13_12","text":"岳阳市","value":"岳阳市","open":true},{"pId":"0_1_13","id":"0_1_13_13","text":"张家界市","value":"张家界市","open":true},{"pId":"0_1_13","id":"0_1_13_14","text":"株洲市","value":"株洲市","open":true},{"pId":"0_1","id":"0_1_14","text":"吉林省( 共10个 )","value":"吉林省","open":true},{"pId":"0_1_14","id":"0_1_14_0","text":"白城市","value":"白城市","open":true},{"pId":"0_1_14","id":"0_1_14_1","text":"白山市","value":"白山市","open":true},{"pId":"0_1_14","id":"0_1_14_2","text":"长春市","value":"长春市","open":true},{"pId":"0_1_14","id":"0_1_14_3","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_14","id":"0_1_14_4","text":"吉林市","value":"吉林市","open":true},{"pId":"0_1_14","id":"0_1_14_5","text":"辽源市","value":"辽源市","open":true},{"pId":"0_1_14","id":"0_1_14_6","text":"四平市","value":"四平市","open":true},{"pId":"0_1_14","id":"0_1_14_7","text":"松原市","value":"松原市","open":true},{"pId":"0_1_14","id":"0_1_14_8","text":"通化市","value":"通化市","open":true},{"pId":"0_1_14","id":"0_1_14_9","text":"延边朝鲜族自治州","value":"延边朝鲜族自治州","open":true},{"pId":"0_1","id":"0_1_15","text":"江苏省( 共13个 )","value":"江苏省","open":true},{"pId":"0_1_15","id":"0_1_15_0","text":"常州市","value":"常州市","open":true},{"pId":"0_1_15","id":"0_1_15_1","text":"淮安市","value":"淮安市","open":true},{"pId":"0_1_15","id":"0_1_15_2","text":"连云港市","value":"连云港市","open":true},{"pId":"0_1_15","id":"0_1_15_3","text":"南京市","value":"南京市","open":true},{"pId":"0_1_15","id":"0_1_15_4","text":"南通市","value":"南通市","open":true},{"pId":"0_1_15","id":"0_1_15_5","text":"苏州市","value":"苏州市","open":true},{"pId":"0_1_15","id":"0_1_15_6","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_1_15","id":"0_1_15_7","text":"泰州市","value":"泰州市","open":true},{"pId":"0_1_15","id":"0_1_15_8","text":"无锡市","value":"无锡市","open":true},{"pId":"0_1_15","id":"0_1_15_9","text":"徐州市","value":"徐州市","open":true},{"pId":"0_1_15","id":"0_1_15_10","text":"盐城市","value":"盐城市","open":true},{"pId":"0_1_15","id":"0_1_15_11","text":"扬州市","value":"扬州市","open":true},{"pId":"0_1_15","id":"0_1_15_12","text":"镇江市","value":"镇江市","open":true},{"pId":"0_1","id":"0_1_16","text":"江西省( 共10个 )","value":"江西省","open":true},{"pId":"0_1_16","id":"0_1_16_0","text":"抚州市","value":"抚州市","open":true},{"pId":"0_1_16","id":"0_1_16_1","text":"赣州市","value":"赣州市","open":true},{"pId":"0_1_16","id":"0_1_16_2","text":"景德镇市","value":"景德镇市","open":true},{"pId":"0_1_16","id":"0_1_16_3","text":"九江市","value":"九江市","open":true},{"pId":"0_1_16","id":"0_1_16_4","text":"南昌市","value":"南昌市","open":true},{"pId":"0_1_16","id":"0_1_16_5","text":"萍乡市","value":"萍乡市","open":true},{"pId":"0_1_16","id":"0_1_16_6","text":"上饶市","value":"上饶市","open":true},{"pId":"0_1_16","id":"0_1_16_7","text":"新余市","value":"新余市","open":true},{"pId":"0_1_16","id":"0_1_16_8","text":"宜春市","value":"宜春市","open":true},{"pId":"0_1_16","id":"0_1_16_9","text":"鹰潭市","value":"鹰潭市","open":true},{"pId":"0_1","id":"0_1_17","text":"辽宁省( 共14个 )","value":"辽宁省","open":true},{"pId":"0_1_17","id":"0_1_17_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_1_17","id":"0_1_17_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_1_17","id":"0_1_17_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_1_17","id":"0_1_17_3","text":"大连市","value":"大连市","open":true},{"pId":"0_1_17","id":"0_1_17_4","text":"丹东市","value":"丹东市","open":true},{"pId":"0_1_17","id":"0_1_17_5","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_1_17","id":"0_1_17_6","text":"阜新市","value":"阜新市","open":true},{"pId":"0_1_17","id":"0_1_17_7","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_1_17","id":"0_1_17_8","text":"锦州市","value":"锦州市","open":true},{"pId":"0_1_17","id":"0_1_17_9","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_1_17","id":"0_1_17_10","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_1_17","id":"0_1_17_11","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_1_17","id":"0_1_17_12","text":"铁岭市","value":"铁岭市","open":true},{"pId":"0_1_17","id":"0_1_17_13","text":"营口市","value":"营口市","open":true},{"pId":"0_1","id":"0_1_18","text":"内蒙古( 共10个 )","value":"内蒙古","open":true},{"pId":"0_1_18","id":"0_1_18_0","text":"包头市","value":"包头市","open":true},{"pId":"0_1_18","id":"0_1_18_1","text":"赤峰市","value":"赤峰市","open":true},{"pId":"0_1_18","id":"0_1_18_2","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_1_18","id":"0_1_18_3","text":"呼和浩特市","value":"呼和浩特市","open":true},{"pId":"0_1_18","id":"0_1_18_4","text":"呼伦贝尔市","value":"呼伦贝尔市","open":true},{"pId":"0_1_18","id":"0_1_18_5","text":"通辽市","value":"通辽市","open":true},{"pId":"0_1_18","id":"0_1_18_6","text":"乌海市","value":"乌海市","open":true},{"pId":"0_1_18","id":"0_1_18_7","text":"锡林郭勒市","value":"锡林郭勒市","open":true},{"pId":"0_1_18","id":"0_1_18_8","text":"兴安市","value":"兴安市","open":true},{"pId":"0_1_18","id":"0_1_18_9","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_19","text":"宁夏回族自治区( 共5个 )","value":"宁夏回族自治区","open":true},{"pId":"0_1_19","id":"0_1_19_0","text":"固原市","value":"固原市","open":true},{"pId":"0_1_19","id":"0_1_19_1","text":"石嘴山市","value":"石嘴山市","open":true},{"pId":"0_1_19","id":"0_1_19_2","text":"吴忠市","value":"吴忠市","open":true},{"pId":"0_1_19","id":"0_1_19_3","text":"银川市","value":"银川市","open":true},{"pId":"0_1_19","id":"0_1_19_4","text":"中卫市","value":"中卫市","open":true},{"pId":"0_1","id":"0_1_20","text":"青海省( 共4个 )","value":"青海省","open":true},{"pId":"0_1_20","id":"0_1_20_0","text":"海东地区","value":"海东地区","open":true},{"pId":"0_1_20","id":"0_1_20_1","text":"海南藏族自治州","value":"海南藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_2","text":"海西蒙古族藏族自治州","value":"海西蒙古族藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_3","text":"西宁市","value":"西宁市","open":true},{"pId":"0_1","id":"0_1_21","text":"山东省( 共17个 )","value":"山东省","open":true},{"pId":"0_1_21","id":"0_1_21_0","text":"滨州市","value":"滨州市","open":true},{"pId":"0_1_21","id":"0_1_21_1","text":"德州市","value":"德州市","open":true},{"pId":"0_1_21","id":"0_1_21_2","text":"东营市","value":"东营市","open":true},{"pId":"0_1_21","id":"0_1_21_3","text":"菏泽市","value":"菏泽市","open":true},{"pId":"0_1_21","id":"0_1_21_4","text":"济南市","value":"济南市","open":true},{"pId":"0_1_21","id":"0_1_21_5","text":"济宁市","value":"济宁市","open":true},{"pId":"0_1_21","id":"0_1_21_6","text":"莱芜市","value":"莱芜市","open":true},{"pId":"0_1_21","id":"0_1_21_7","text":"聊城市","value":"聊城市","open":true},{"pId":"0_1_21","id":"0_1_21_8","text":"临沂市","value":"临沂市","open":true},{"pId":"0_1_21","id":"0_1_21_9","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_21","id":"0_1_21_10","text":"日照市","value":"日照市","open":true},{"pId":"0_1_21","id":"0_1_21_11","text":"泰安市","value":"泰安市","open":true},{"pId":"0_1_21","id":"0_1_21_12","text":"威海市","value":"威海市","open":true},{"pId":"0_1_21","id":"0_1_21_13","text":"潍坊市","value":"潍坊市","open":true},{"pId":"0_1_21","id":"0_1_21_14","text":"烟台市","value":"烟台市","open":true},{"pId":"0_1_21","id":"0_1_21_15","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_1_21","id":"0_1_21_16","text":"淄博市","value":"淄博市","open":true},{"pId":"0_1","id":"0_1_22","text":"山西省( 共12个 )","value":"山西省","open":true},{"pId":"0_1_22","id":"0_1_22_0","text":"长治市","value":"长治市","open":true},{"pId":"0_1_22","id":"0_1_22_1","text":"大同市","value":"大同市","open":true},{"pId":"0_1_22","id":"0_1_22_2","text":"晋城市","value":"晋城市","open":true},{"pId":"0_1_22","id":"0_1_22_3","text":"晋中市","value":"晋中市","open":true},{"pId":"0_1_22","id":"0_1_22_4","text":"临汾市","value":"临汾市","open":true},{"pId":"0_1_22","id":"0_1_22_5","text":"吕梁市","value":"吕梁市","open":true},{"pId":"0_1_22","id":"0_1_22_6","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_22","id":"0_1_22_7","text":"朔州市","value":"朔州市","open":true},{"pId":"0_1_22","id":"0_1_22_8","text":"太原市","value":"太原市","open":true},{"pId":"0_1_22","id":"0_1_22_9","text":"忻州市","value":"忻州市","open":true},{"pId":"0_1_22","id":"0_1_22_10","text":"阳泉市","value":"阳泉市","open":true},{"pId":"0_1_22","id":"0_1_22_11","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_23","text":"陕西省( 共9个 )","value":"陕西省","open":true},{"pId":"0_1_23","id":"0_1_23_0","text":"安康市","value":"安康市","open":true},{"pId":"0_1_23","id":"0_1_23_1","text":"宝鸡市","value":"宝鸡市","open":true},{"pId":"0_1_23","id":"0_1_23_2","text":"汉中市","value":"汉中市","open":true},{"pId":"0_1_23","id":"0_1_23_3","text":"商洛市","value":"商洛市","open":true},{"pId":"0_1_23","id":"0_1_23_4","text":"渭南市","value":"渭南市","open":true},{"pId":"0_1_23","id":"0_1_23_5","text":"西安市","value":"西安市","open":true},{"pId":"0_1_23","id":"0_1_23_6","text":"咸阳市","value":"咸阳市","open":true},{"pId":"0_1_23","id":"0_1_23_7","text":"延安市","value":"延安市","open":true},{"pId":"0_1_23","id":"0_1_23_8","text":"榆林市","value":"榆林市","open":true},{"pId":"0_1","id":"0_1_24","text":"上海市( 共19个 )","value":"上海市","open":true},{"pId":"0_1_24","id":"0_1_24_0","text":"宝山区","value":"宝山区","open":true},{"pId":"0_1_24","id":"0_1_24_1","text":"长宁区","value":"长宁区","open":true},{"pId":"0_1_24","id":"0_1_24_2","text":"崇明县","value":"崇明县","open":true},{"pId":"0_1_24","id":"0_1_24_3","text":"奉贤区","value":"奉贤区","open":true},{"pId":"0_1_24","id":"0_1_24_4","text":"虹口区","value":"虹口区","open":true},{"pId":"0_1_24","id":"0_1_24_5","text":"黄浦区","value":"黄浦区","open":true},{"pId":"0_1_24","id":"0_1_24_6","text":"嘉定区","value":"嘉定区","open":true},{"pId":"0_1_24","id":"0_1_24_7","text":"金山区","value":"金山区","open":true},{"pId":"0_1_24","id":"0_1_24_8","text":"静安区","value":"静安区","open":true},{"pId":"0_1_24","id":"0_1_24_9","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_24","id":"0_1_24_10","text":"闵行区","value":"闵行区","open":true},{"pId":"0_1_24","id":"0_1_24_11","text":"普陀区","value":"普陀区","open":true},{"pId":"0_1_24","id":"0_1_24_12","text":"浦东新区","value":"浦东新区","open":true},{"pId":"0_1_24","id":"0_1_24_13","text":"青浦区","value":"青浦区","open":true},{"pId":"0_1_24","id":"0_1_24_14","text":"上海市区","value":"上海市区","open":true},{"pId":"0_1_24","id":"0_1_24_15","text":"松江区","value":"松江区","open":true},{"pId":"0_1_24","id":"0_1_24_16","text":"徐汇区","value":"徐汇区","open":true},{"pId":"0_1_24","id":"0_1_24_17","text":"杨浦区","value":"杨浦区","open":true},{"pId":"0_1_24","id":"0_1_24_18","text":"闸北区","value":"闸北区","open":true},{"pId":"0_1","id":"0_1_25","text":"四川省( 共21个 )","value":"四川省","open":true},{"pId":"0_1_25","id":"0_1_25_0","text":"阿坝藏族羌族自治州","value":"阿坝藏族羌族自治州","open":true},{"pId":"0_1_25","id":"0_1_25_1","text":"巴中市","value":"巴中市","open":true},{"pId":"0_1_25","id":"0_1_25_2","text":"成都市","value":"成都市","open":true},{"pId":"0_1_25","id":"0_1_25_3","text":"达州市","value":"达州市","open":true},{"pId":"0_1_25","id":"0_1_25_4","text":"德阳市","value":"德阳市","open":true},{"pId":"0_1_25","id":"0_1_25_5","text":"甘孜市","value":"甘孜市","open":true},{"pId":"0_1_25","id":"0_1_25_6","text":"广安市","value":"广安市","open":true},{"pId":"0_1_25","id":"0_1_25_7","text":"广元市","value":"广元市","open":true},{"pId":"0_1_25","id":"0_1_25_8","text":"乐山市","value":"乐山市","open":true},{"pId":"0_1_25","id":"0_1_25_9","text":"凉山市","value":"凉山市","open":true},{"pId":"0_1_25","id":"0_1_25_10","text":"泸州市","value":"泸州市","open":true},{"pId":"0_1_25","id":"0_1_25_11","text":"眉山市","value":"眉山市","open":true},{"pId":"0_1_25","id":"0_1_25_12","text":"绵阳市","value":"绵阳市","open":true},{"pId":"0_1_25","id":"0_1_25_13","text":"南充市","value":"南充市","open":true},{"pId":"0_1_25","id":"0_1_25_14","text":"内江市","value":"内江市","open":true},{"pId":"0_1_25","id":"0_1_25_15","text":"攀枝花市","value":"攀枝花市","open":true},{"pId":"0_1_25","id":"0_1_25_16","text":"遂宁市","value":"遂宁市","open":true},{"pId":"0_1_25","id":"0_1_25_17","text":"雅安市","value":"雅安市","open":true},{"pId":"0_1_25","id":"0_1_25_18","text":"宜宾市","value":"宜宾市","open":true},{"pId":"0_1_25","id":"0_1_25_19","text":"资阳市","value":"资阳市","open":true},{"pId":"0_1_25","id":"0_1_25_20","text":"自贡市","value":"自贡市","open":true},{"pId":"0_1","id":"0_1_26","text":"台湾( 共1个 )","value":"台湾","open":true},{"pId":"0_1_26","id":"0_1_26_0","text":"台北市","value":"台北市","open":true},{"pId":"0_1","id":"0_1_27","text":"天津市( 共1个 )","value":"天津市","open":true},{"pId":"0_1_27","id":"0_1_27_0","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1","id":"0_1_28","text":"西藏自治区( 共2个 )","value":"西藏自治区","open":true},{"pId":"0_1_28","id":"0_1_28_0","text":"阿里市","value":"阿里市","open":true},{"pId":"0_1_28","id":"0_1_28_1","text":"日喀则市","value":"日喀则市","open":true},{"pId":"0_1","id":"0_1_29","text":"香港特别行政区( 共1个 )","value":"香港特别行政区","open":true},{"pId":"0_1_29","id":"0_1_29_0","text":"香港","value":"香港","open":true},{"pId":"0_1","id":"0_1_30","text":"新疆维吾尔族自治区( 共11个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_1_30","id":"0_1_30_0","text":"巴音郭楞市","value":"巴音郭楞市","open":true},{"pId":"0_1_30","id":"0_1_30_1","text":"哈密市","value":"哈密市","open":true},{"pId":"0_1_30","id":"0_1_30_2","text":"和田市","value":"和田市","open":true},{"pId":"0_1_30","id":"0_1_30_3","text":"喀什地区","value":"喀什地区","open":true},{"pId":"0_1_30","id":"0_1_30_4","text":"克拉玛依市","value":"克拉玛依市","open":true},{"pId":"0_1_30","id":"0_1_30_5","text":"克孜勒苏柯州","value":"克孜勒苏柯州","open":true},{"pId":"0_1_30","id":"0_1_30_6","text":"石河子市","value":"石河子市","open":true},{"pId":"0_1_30","id":"0_1_30_7","text":"塔城市","value":"塔城市","open":true},{"pId":"0_1_30","id":"0_1_30_8","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_1_30","id":"0_1_30_9","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_1_30","id":"0_1_30_10","text":"伊犁市","value":"伊犁市","open":true},{"pId":"0_1","id":"0_1_31","text":"云南省( 共12个 )","value":"云南省","open":true},{"pId":"0_1_31","id":"0_1_31_0","text":"保山市","value":"保山市","open":true},{"pId":"0_1_31","id":"0_1_31_1","text":"楚雄彝族自治州","value":"楚雄彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_2","text":"大理白族自治州","value":"大理白族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_3","text":"红河哈尼族彝族自治州","value":"红河哈尼族彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_4","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_31","id":"0_1_31_5","text":"丽江市","value":"丽江市","open":true},{"pId":"0_1_31","id":"0_1_31_6","text":"临沧市","value":"临沧市","open":true},{"pId":"0_1_31","id":"0_1_31_7","text":"曲靖市","value":"曲靖市","open":true},{"pId":"0_1_31","id":"0_1_31_8","text":"思茅市","value":"思茅市","open":true},{"pId":"0_1_31","id":"0_1_31_9","text":"文山市","value":"文山市","open":true},{"pId":"0_1_31","id":"0_1_31_10","text":"玉溪市","value":"玉溪市","open":true},{"pId":"0_1_31","id":"0_1_31_11","text":"昭通市","value":"昭通市","open":true},{"pId":"0_1","id":"0_1_32","text":"浙江省( 共12个 )","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_1_32","id":"0_1_32_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_1_32","id":"0_1_32_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_1_32","id":"0_1_32_3","text":"金华市","value":"金华市","open":true},{"pId":"0_1_32","id":"0_1_32_4","text":"丽水市","value":"丽水市","open":true},{"pId":"0_1_32","id":"0_1_32_5","text":"宁波市","value":"宁波市","open":true},{"pId":"0_1_32","id":"0_1_32_6","text":"衢州市","value":"衢州市","open":true},{"pId":"0_1_32","id":"0_1_32_7","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_1_32","id":"0_1_32_8","text":"台州市","value":"台州市","open":true},{"pId":"0_1_32","id":"0_1_32_9","text":"温州市","value":"温州市","open":true},{"pId":"0_1_32","id":"0_1_32_10","text":"浙江省","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_11","text":"舟山市","value":"舟山市","open":true},{"pId":"0_1","id":"0_1_33","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_1_33","id":"0_1_33_0","text":"重庆市区","value":"重庆市区","open":true}], + + TREE:[{id: -1, pId: -2, value: "根目录", text: "根目录"}, + {id: 1, pId: -1, value: "第一级目录1", text: "第一级目录1"}, + {id: 11, pId: 1, value: "第二级文件1", text: "第二级文件1"}, + {id: 12, pId: 1, value: "第二级目录2", text: "第二级目录2"}, + {id: 121, pId: 12, value: "第三级目录1", text: "第三级目录1"}, + {id: 122, pId: 12, value: "第三级文件1", text: "第三级文件1"}, + {id: 1211, pId: 121, value: "第四级目录1", text: "第四级目录1"}, + {id: 12111, pId: 1211, value: "第五级文件1", text: "第五级文件1"}, + {id: 2, pId: -1, value: "第一级目录2", text: "第一级目录2"}, + {id: 21, pId: 2, value: "第二级目录3", text: "第二级目录3"}, + {id: 22, pId: 2, value: "第二级文件2", text: "第二级文件2"}, + {id: 211, pId: 21, value: "第三级目录2", text: "第三级目录2"}, + {id: 212, pId: 21, value: "第三级文件2", text: "第三级文件2"}, + {id: 2111, pId: 211, value: "第四级文件1", text: "第四级文件1"}] }; diff --git a/demo/css/main.css b/demo/css/main.css index ab550ecc8..60476fa50 100644 --- a/demo/css/main.css +++ b/demo/css/main.css @@ -45,3 +45,6 @@ body { .bi-theme-dark body { background-color: #191B2B; } +.demo-editor { + border: 1px solid #cccccc; +} diff --git a/demo/js/config/base.js b/demo/js/config/base.js index f3c020ded..f983e4a55 100644 --- a/demo/js/config/base.js +++ b/demo/js/config/base.js @@ -1,7 +1,7 @@ Demo.BASE_CONFIG = [{ id: 2, text: "基础控件", - open: true + open: false }, { pId: 2, text: "bi.label", diff --git a/demo/js/config/case.js b/demo/js/config/case.js index 959d69ff1..3b477402b 100644 --- a/demo/js/config/case.js +++ b/demo/js/config/case.js @@ -1,7 +1,7 @@ Demo.CASE_CONFIG = [{ id: 3, text: "实例控件", - open: true, + open: false }, { pId: 3, id: 301, diff --git a/demo/js/config/widget.js b/demo/js/config/widget.js index 1ec8d5c69..500e963ce 100644 --- a/demo/js/config/widget.js +++ b/demo/js/config/widget.js @@ -1,4 +1,5 @@ Demo.WIDGET_CONFIG = [{ +<<<<<<< HEAD id: 4, text: "详细控件" }, { @@ -49,4 +50,258 @@ Demo.WIDGET_CONFIG = [{ pId: 4, text: "bi.custom_date_time", value: "demo.custom_date_time" -}]; \ No newline at end of file +}]; +======= + id: 4, + text: "详细控件", + open: true + }, { + id: 400, + pId: 4, + text: "tree" + }, { + pId: 400, + text: "bi.multi_tree_combo", + value: "demo.multi_tree_combo" + }, { + id: 401, + pId: 4, + text: "table" + }, { + pId: 401, + text: "bi.preview_table", + value: "demo.preview_table" + }, { + pId: 401, + text: "bi.responsive_table", + value: "demo.responsive_table" + }, { + pId: 401, + text: "bi.excel_table", + value: "demo.excel_table" + }, { + pId: 4, + id: 402, + text: "年份控件", + open: false + }, { + pId: 402, + text: "bi.year_combo", + value: "demo.year" + }, { + pId: 4, + id: 403, + text: "月份控件", + open: false + }, { + pId: 403, + text: "bi.month_combo", + value: "demo.month" + }, { + pId: 4, + id: 404, + text: "季度控件", + open: false + }, { + pId: 404, + text: "bi.quarter_combo", + value: "demo.quarter" + }, { + pId: 4, + id: 405, + text: "下拉列表", + open: false + }, { + pId: 405, + text: "bi.down_list_combo", + value: "demo.down_list" + }, { + pId: 4, + id: 406, + text: "文本框控件", + open: false + }, { + pId: 406, + text: "bi.text_editor", + value: "demo.text_editor" + }, { + pId: 406, + text: "bi.search_editor", + value: "demo.search_editor" + }, { + pId: 406, + text: "bi.sign_editor", + value: "demo.sign_editor" + }, { + pId: 406, + text: "bi.sign_initial_editor", + value: "demo.sign_initial_editor" + }, { + pId: 406, + text: "bi.sign_style_editor", + value: "demo.sign_style_editor" + }, { + pId: 406, + text: "bi.state_editor", + value: "demo.state_editor" + }, { + pId: 406, + text: "bi.clear_editor", + value: "demo.clear_editor" + }, { + pId: 406, + text: "bi.record_editor", + value: "demo.record_editor" + }, { + pId: 406, + text: "bi.shelter_editor", + value: "demo.shelter_editor" + }, + { + pId: 4, + id: 407, + text: "下拉框控件", + open: false + }, { + pId: 407, + text: "bi.text_value_combo", + value: "demo.text_value_combo" + }, { + pId: 407, + text: "bi.text_value_check_combo", + value: "demo.text_value_check_combo" + }, { + pId: 407, + text: "bi.text_value_down_list_combo", + value: "demo.text_value_down_list_combo" + }, { + pId: 407, + text: "bi.static_combo", + value: "demo.static_combo" + }, { + pId: 407, + text: "bi.icon_combo", + value: "demo.icon_combo" + }, { + pId: 407, + text: "bi.formula_combo", + value: "demo.formula_combo" + }, { + pId: 4, + id: 408, + text: "选择字段列表", + open: false + }, { + pId: 408, + text: "bi.placeholder" + }, { + pId: 4, + id: 409, + text: "公式编辑器", + open: false + }, { + pId: 409, + text: "bi.placeholder" + }, { + pId: 4, + id: 410, + text: "数值区间控件" + }, { + pId: 410, + text: "bi.numerical_interval", + value: "demo.numberical_interval" + }, { + pId: 4, + id: 411, + text: "下拉复选框有确定按钮" + }, { + pId: 411, + text: "bi.multi_select_combo", + value: "demo.multi_select_combo" + }, { + pId: 4, + id: 412, + text: "简单日期控件" + }, { + pId: 412, + text: "bi.date_combo", + value: "demo.date" + }, { + pId: 412, + text: "bi.date_pane_widget", + value: "demo.date_pane_widget" + }, { + pId: 412, + text: "bi.year_month_combo", + value: "demo.year_month_combo" + },{ + pId: 412, + text: "bi.year_quarter_combo", + value: "demo.year_quarter_combo" + },{ + pId: 4, + id: 413, + text: "简单下拉树" + }, { + pId: 413, + text: "bi.single_tree_combo", + value: "demo.single_tree_combo" + }, { + pId: 413, + text: "bi.multilayer_single_tree_combo", + value: "demo.multilayer_single_tree_combo" + }, { + pId: 4, + id: 414, + text: "可选下拉树" + }, { + pId: 414, + text: "bi.select_tree_combo", + value: "demo.select_tree_combo" + }, { + pId: 414, + text: "bi.multilayer_select_tree_combo", + value: "demo.multilayer_select_tree_combo" + }, { + pId: 4, + id: 415, + text: "路径选择" + }, { + pId: 415, + text: "bi.path_chooser", + value: "demo.path_chooser" + }, { + pId: 415, + text: "bi.direction_path_chooser", + value: "demo.direction_path_chooser" + }, { + pId: 4, + id: 416, + text: "关联视图" + }, { + pId: 416, + text: "bi.relation_view", + value: "demo.relation_view" + }, { + pId: 4, + id: 417, + text: "布局" + }, { + pId: 417, + text: "bi.adaptive_arrangement", + value: "demo.adaptive_arrangement" + }, { + pId: 417, + text: "bi.interactive_arrangement", + value: "demo.interactive_arrangement" + }, { + pId: 4, + id: 418, + text: "提示对话框" + }, { + pId: 418, + text: "bi.dialog", + value: "demo.dialog" + } +]; +>>>>>>> 3903ca444e161ac208f69ba22c0a3136d7a0fa81 diff --git a/demo/js/widget/arrangment/demo.adaptive_arrangement.js b/demo/js/widget/arrangment/demo.adaptive_arrangement.js new file mode 100644 index 000000000..f6bb68f97 --- /dev/null +++ b/demo/js/widget/arrangment/demo.adaptive_arrangement.js @@ -0,0 +1,121 @@ +Demo.AdaptiveArrangement = BI.inherit(BI.Widget, { + + _createItem: function () { + var self = this; + var id = BI.UUID(); + var item = BI.createWidget({ + type: "bi.text_button", + id: id, + cls: "layout-bg" + BI.random(1, 8), + handler: function () { + self.arrangement.deleteRegion(id); + } + }); + item.setValue(item.attr("id")); + return item; + }, + + render: function () { + var self = this; + this.arrangement = BI.createWidget({ + type: "bi.adaptive_arrangement", + layoutType: BI.Arrangement.LAYOUT_TYPE.ADAPTIVE, + cls: "mvc-border", + width: 800, + height: 400, + items: [] + }); + var drag = BI.createWidget({ + type: "bi.label", + cls: "mvc-border", + width: 100, + height: 25, + text: "drag me" + }); + + // drag.element.draggable && + drag.element.draggable({ + revert: true, + cursorAt: { + left: 0, + top: 0 + }, + drag: function (e, ui) { + self.arrangement.setPosition({ + left: ui.position.left, + top: ui.position.top + }, { + width: 300, + height: 200 + }) + }, + stop: function (e, ui) { + self.arrangement.addRegion({ + el: self._createItem() + }); + }, + helper: function (e) { + var helper = self.arrangement.getHelper(); + return helper.element; + } + }); + + BI.createWidget({ + type: "bi.absolute", + items: [{ + el: drag, + left: 30, + top: 450 + }, { + el: this.arrangement, + left: 30, + top: 30 + }, { + el: { + type: "bi.button", + text: "回撤", + height: 25, + handler: function () { + //self.arrangement.revoke(); + } + }, + left: 130, + top: 450 + }, { + el: { + type: "bi.button", + text: "getAllRegions", + height: 25, + handler: function () { + var items = []; + BI.each(self.arrangement.getAllRegions(), function (i, region) { + items.push({ + id: region.id, + left: region.left, + top: region.top, + width: region.width, + height: region.height + }); + }); + BI.Msg.toast(JSON.stringify(items)); + } + }, + left: 230, + top: 450 + }, { + el: { + type: "bi.button", + text: "relayout", + height: 25, + handler: function () { + self.arrangement.relayout(); + } + }, + left: 330, + top: 450 + }] + }); + } +}); + +BI.shortcut("demo.adaptive_arrangement", Demo.AdaptiveArrangement); \ No newline at end of file diff --git a/demo/js/widget/demo.interactivearrangement.js b/demo/js/widget/arrangment/demo.interactive_arrangement.js similarity index 100% rename from demo/js/widget/demo.interactivearrangement.js rename to demo/js/widget/arrangment/demo.interactive_arrangement.js diff --git a/demo/js/widget/combo/demo.formula_combo.js b/demo/js/widget/combo/demo.formula_combo.js new file mode 100644 index 000000000..71a42f8e2 --- /dev/null +++ b/demo/js/widget/combo/demo.formula_combo.js @@ -0,0 +1,31 @@ +/** + * Created by Dailer on 2017/7/12. + */ +Demo.FormulaCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + + var self = this; + + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.formula_combo", + fieldItems: [{ + text: "A", + value: "A", + fieldType: 16 + }], + width: 200, + height: 30 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.formula_combo", Demo.FormulaCombo); \ No newline at end of file diff --git a/demo/js/widget/combo/demo.icon_combo.js b/demo/js/widget/combo/demo.icon_combo.js new file mode 100644 index 000000000..90a4344c8 --- /dev/null +++ b/demo/js/widget/combo/demo.icon_combo.js @@ -0,0 +1,38 @@ +/** + * Created by Dailer on 2017/7/12. + */ +Demo.IconCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + + var self = this; + + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.icon_combo", + ref:function(_ref){ + self.refs=_ref; + }, + // iconClass: "pull-down-ha-font", + items: [{ + value: "第一项", + iconClass: "delete-font" + }, { + value: "第二项", + iconClass: "rename-font" + }, { + value: "第三项", + iconClass: "move-font" + }] + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.icon_combo", Demo.IconCombo); \ No newline at end of file diff --git a/demo/js/widget/combo/demo.static_combo.js b/demo/js/widget/combo/demo.static_combo.js new file mode 100644 index 000000000..a62c03d03 --- /dev/null +++ b/demo/js/widget/combo/demo.static_combo.js @@ -0,0 +1,45 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.StaticCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + + beforeMounted: function () { + this.refs.setValue(2); + }, + + render: function () { + + var self = this; + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.static_combo", + text: "Value 不变", + width: 300, + ref: function (_ref) { + self.refs = _ref; + }, + items: [ + { + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + } + ] + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.static_combo", Demo.StaticCombo); \ No newline at end of file diff --git a/demo/js/widget/combo/demo.text_value_combo.js b/demo/js/widget/combo/demo.text_value_combo.js new file mode 100644 index 000000000..4966600df --- /dev/null +++ b/demo/js/widget/combo/demo.text_value_combo.js @@ -0,0 +1,60 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.TextValueCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.text_value_combo", + text: "天气热死了", + width: 300, + items: [{ + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + },{ + type: "bi.text_value_check_combo", + text: "天气热死了", + width: 300, + items: [{ + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + },{ + type: "bi.text_value_combo", + text: "天气热死了", + width: 300, + items: [{ + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.text_value_combo", Demo.TextValueCombo); \ No newline at end of file diff --git a/demo/js/widget/combo/demo.text_value_down_list_combo.js b/demo/js/widget/combo/demo.text_value_down_list_combo.js new file mode 100644 index 000000000..3be823d0b --- /dev/null +++ b/demo/js/widget/combo/demo.text_value_down_list_combo.js @@ -0,0 +1,57 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.TextValueDownListCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + + beforeMounted:function(){ + this.refs.setValue(2); + }, + + render: function () { + + var self = this; + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.label", + cls: "layout-bg2", + text: "分组+二级", + width: 300 + }, { + type: "bi.text_value_down_list_combo", + text: "天气热死了", + width: 300, + ref: function (_ref) { + self.refs = _ref; + }, + items: [ + [{ + el: { + text: "MVC-1", + value: 1 + }, + children: [{ + text: "MVC-1-1", + value: 11 + }] + }], + [{ + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + ] + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.text_value_down_list_combo", Demo.TextValueDownListCombo); \ No newline at end of file diff --git a/demo/js/widget/combo/demo.text_vlaue_check_combo.js b/demo/js/widget/combo/demo.text_vlaue_check_combo.js new file mode 100644 index 000000000..bb0638da7 --- /dev/null +++ b/demo/js/widget/combo/demo.text_vlaue_check_combo.js @@ -0,0 +1,32 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.text_value_check_combo", + text: "天气热死了", + width: 300, + items: [{ + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.text_value_check_combo", Demo.TextValueCheckCombo); \ No newline at end of file diff --git a/demo/js/widget/date/demo.date.js b/demo/js/widget/date/demo.date.js new file mode 100644 index 000000000..8b5665ce6 --- /dev/null +++ b/demo/js/widget/date/demo.date.js @@ -0,0 +1,31 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.Date = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-date" + }, + + _init: function () { + Demo.Date.superclass._init.apply(this, arguments); + }, + + render: function () { + + return { + type: "bi.horizontal_auto", + vgap: 10, + items: [{ + type: "bi.date_combo", + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + height: 50, + width: 300 + }] + } + } +}) + +BI.shortcut("demo.date", Demo.Date); \ No newline at end of file diff --git a/demo/js/widget/date/demo.datepane.js b/demo/js/widget/date/demo.datepane.js new file mode 100644 index 000000000..c3ba442fd --- /dev/null +++ b/demo/js/widget/date/demo.datepane.js @@ -0,0 +1,39 @@ +Demo.DatePane = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-datepane" + }, + render: function () { + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.vertical", + vgap: 10, + items: [{ + type: "bi.label", + cls: "layout-bg2", + text: "bi.date_pane_widget" + }, { + type: "bi.date_pane_widget", + selectedTime: { + year: 2017, + month: 12, + day: 11 + }, + height:300 + }, + { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast("date" + JSON.stringify(datepane.getValue())); + } + } + ], + width: "50%" + }] + } + } +}) + +BI.shortcut("demo.date_pane_widget", Demo.DatePane); \ No newline at end of file diff --git a/demo/js/widget/dialog/demo.dialog.js b/demo/js/widget/dialog/demo.dialog.js new file mode 100644 index 000000000..2e0ec34b0 --- /dev/null +++ b/demo/js/widget/dialog/demo.dialog.js @@ -0,0 +1,27 @@ +Demo.DialogView = BI.inherit(BI.Widget, { + + render: function () { + var items = [{ + el: { + type: 'bi.button', + text: '弹出对话框', + level: 'common', + height: 30 + } + }]; + BI.each(items, function (i, item) { + item.el.handler = function () { + BI.Msg.alert('提示', "这是一段可以换行的文字,为了使它换行我要多写几个字,但是我又凑不够这么多的字,万般焦急下,只能随便写写"); + } + }); + + return { + type: "bi.left", + vgap: 200, + hgap: 20, + items: items + } + } +}); + +BI.shortcut("demo.dialog", Demo.DialogView); \ No newline at end of file diff --git a/demo/js/widget/downlist/demo.downlist.js b/demo/js/widget/downlist/demo.downlist.js new file mode 100644 index 000000000..41d22d3df --- /dev/null +++ b/demo/js/widget/downlist/demo.downlist.js @@ -0,0 +1,136 @@ +Demo.Downlist = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-downlist" + }, + + mounted: function () { + var downlist = this.downlist; + var label = this.label; + downlist.on(BI.DownListCombo.EVENT_CHANGE, function (value, fatherValue) { + label.setValue(JSON.stringify(downlist.getValue())); + }); + + this.downlist.on(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { + label.setValue(JSON.stringify(downlist.getValue())); + }); + }, + + + render: function () { + self = this; + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.down_list_combo", + ref: function (_ref) { + self.downlist = _ref; + }, + cls:"layout-bg3", + height: 30, + width: 100, + items: [ + [{ + el: { + text: "column 1111", + iconCls1: "check-mark-e-font", + value: 11 + }, + children: [{ + text: "column 1.1", + value: 21, + cls: "dot-e-font", + selected: true + }, { + text: "column 1.222222222222222222222222222222222222", + cls: "dot-e-font", + value: 22, + }] + }], + [{ + el: { + type: "bi.icon_text_icon_item", + text: "column 2", + iconCls1: "chart-type-e-font", + cls: "dot-e-font", + value: 12 + }, + disabled: true, + children: [{ + type: "bi.icon_text_item", + cls: "dot-e-font", + height: 25, + text: "column 2.1", + value: 11 + }, { + text: "column 2.2", + value: 12, + cls: "dot-e-font" + }] + }], + [{ + text: "column 8", + value: 18, + cls: "dot-e-font", + selected: true + }, + { + + text: "column 9", + cls: "dot-e-font", + value: 19 + } + ], + [{ + text: "column 10", + value: 20, + cls: "dot-e-font", + selected: true + }, + { + + text: "column 11", + cls: "dot-e-font", + value: 21 + }, + { + + text: "column 12", + cls: "dot-e-font", + value: 22 + }, + { + + text: "column 13", + cls: "dot-e-font", + value: 23 + }, + { + + text: "column 14", + cls: "dot-e-font", + value: 24 + }, + { + + text: "column 15", + cls: "dot-e-font", + value: 23 + } + ] + + ] + }, { + type: "bi.label", + text: "显示选择值", + width:500, + cls:"layout-bg4", + ref: function (_ref) { + self.label = _ref; + } + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.down_list", Demo.Downlist); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.adapt_editor.js b/demo/js/widget/editor/demo.adapt_editor.js new file mode 100644 index 000000000..e32b1801c --- /dev/null +++ b/demo/js/widget/editor/demo.adapt_editor.js @@ -0,0 +1,46 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.AdaptEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + + + //这东西好奇怪,不支持设置宽度,那么渲染出来宽度几乎没有,无奈之下只能假装给他个默认值了 + beforeMounted: function () { + this.refs.setValue("Winter is coming !") + }, + + render: function () { + var self = this; + var editor = BI.createWidget({ + type: "bi.adapt_editor", + cls: "layout-bg5", + ref: function (_ref) { + self.refs = _ref; + } + }) + + var text=["You know nothing! Jon Snow","A Lannister always pays his debts.","Power is a curious thing."] + + return { + type: "bi.horizontal_auto", + items: [{ + el: editor + }, { + type: "bi.button", + text: "为了展示长度真的是可变的,每点一下就换一行字", + handler: function () { + var temp=text.shift(); + editor.setValue(temp); + text.push(temp); + } + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.adapt_editor", Demo.AdaptEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.clear_editor.js b/demo/js/widget/editor/demo.clear_editor.js new file mode 100644 index 000000000..7e683b62b --- /dev/null +++ b/demo/js/widget/editor/demo.clear_editor.js @@ -0,0 +1,22 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.ClearEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.clear_editor", + cls: "bi-border", + width: 300, + watermark: "这个是带清除按钮的" + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.clear_editor", Demo.ClearEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.record_editor.js b/demo/js/widget/editor/demo.record_editor.js new file mode 100644 index 000000000..bb7de6923 --- /dev/null +++ b/demo/js/widget/editor/demo.record_editor.js @@ -0,0 +1,22 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.RecordEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.record_editor", + cls: "bi-border", + width: 300, + watermark: "这个是可以记录输入的" + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.record_editor", Demo.RecordEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.search_editor.js b/demo/js/widget/editor/demo.search_editor.js new file mode 100644 index 000000000..020bf0d25 --- /dev/null +++ b/demo/js/widget/editor/demo.search_editor.js @@ -0,0 +1,29 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.SearchEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.search_editor", + width: 300, + watermark:"添加合法性判断", + errorText: "长度必须大于4", + validationChecker:function(){ + return this.getValue().length > 4 ? true : false + } + },{ + type: "bi.small_search_editor", + width: 300, + watermark:"这个是 small,小一号" + }], + vgap:20 + } + } +}) + +BI.shortcut("demo.search_editor", Demo.SearchEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.shelter_editor.js b/demo/js/widget/editor/demo.shelter_editor.js new file mode 100644 index 000000000..74914201b --- /dev/null +++ b/demo/js/widget/editor/demo.shelter_editor.js @@ -0,0 +1,41 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.ClearEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + var editor; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.shelter_editor", + cls: "bi-border", + ref:function(_ref){ + editor=_ref; + }, + width: 300, + watermark: "这个是带标记的" + },{ + type:"bi.button", + text:"setValue", + width:300, + handler:function(){ + editor.setValue("凛冬将至"); + } + },{ + type:"bi.button", + text:"doHighLight", + width:300, + handler:function(){ + editor.doHighLight(); + console.log(editor.getState()); + } + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.shelter_editor", Demo.ClearEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.sign_editor.js b/demo/js/widget/editor/demo.sign_editor.js new file mode 100644 index 000000000..90f4f8448 --- /dev/null +++ b/demo/js/widget/editor/demo.sign_editor.js @@ -0,0 +1,24 @@ +/** + * Created by Dailer on 2017/7/14. + */ +Demo.SignEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.sign_editor", + // cls:"layout-bg5", + value: "123", + text: "456", + width: 300 + }], + vgap: 20 + + } + } +}) + +BI.shortcut("demo.sign_editor", Demo.SignEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.sign_initial_editor.js b/demo/js/widget/editor/demo.sign_initial_editor.js new file mode 100644 index 000000000..480d4d498 --- /dev/null +++ b/demo/js/widget/editor/demo.sign_initial_editor.js @@ -0,0 +1,24 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.SignInitialEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.sign_initial_editor", + cls:"layout-bg5", + value:"123", + text:"456", + width: 300 + }], + vgap:20 + + } + } +}) + +BI.shortcut("demo.sign_initial_editor", Demo.SignInitialEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.sign_style_editor.js b/demo/js/widget/editor/demo.sign_style_editor.js new file mode 100644 index 000000000..81f66c0e2 --- /dev/null +++ b/demo/js/widget/editor/demo.sign_style_editor.js @@ -0,0 +1,22 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.SignStyleEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.sign_style_editor", + cls:"layout-bg5", + value:"12313", + width: 300 + }], + vgap:20 + } + } +}) + +BI.shortcut("demo.sign_style_editor", Demo.SignStyleEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.state_editor.js b/demo/js/widget/editor/demo.state_editor.js new file mode 100644 index 000000000..dedc7d024 --- /dev/null +++ b/demo/js/widget/editor/demo.state_editor.js @@ -0,0 +1,24 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.StateEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.state_editor", + cls:"bi-border", + value:"123", + text:"456", + width: 300 + }], + vgap:20 + + } + } +}) + +BI.shortcut("demo.state_editor", Demo.StateEditor); \ No newline at end of file diff --git a/demo/js/widget/editor/demo.text_editor.js b/demo/js/widget/editor/demo.text_editor.js new file mode 100644 index 000000000..db748cfbe --- /dev/null +++ b/demo/js/widget/editor/demo.text_editor.js @@ -0,0 +1,28 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.TextEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.text_editor", + watermark:"这是水印,watermark", + width: 300 + },{ + type: "bi.text_editor", + watermark:"这个不予许空", + allowBlank: false, + errorText: "非空!", + width: 300 + }], + vgap:20 + + } + } +}) + +BI.shortcut("demo.text_editor", Demo.TextEditor); \ No newline at end of file diff --git a/demo/js/widget/month/demo.month.js b/demo/js/widget/month/demo.month.js new file mode 100644 index 000000000..c40ccdad9 --- /dev/null +++ b/demo/js/widget/month/demo.month.js @@ -0,0 +1,20 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.Month = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.month_combo", + width: 300 + }] + + } + } +}) + +BI.shortcut("demo.month", Demo.Month); \ No newline at end of file diff --git a/demo/js/widget/demo.multiselectcombo.js b/demo/js/widget/multiselect/demo.multi_select_combo.js similarity index 91% rename from demo/js/widget/demo.multiselectcombo.js rename to demo/js/widget/multiselect/demo.multi_select_combo.js index 431982b93..57b3df91f 100644 --- a/demo/js/widget/demo.multiselectcombo.js +++ b/demo/js/widget/multiselect/demo.multi_select_combo.js @@ -44,8 +44,8 @@ Demo.MultiSelectCombo = BI.inherit(BI.Widget, { var search = BI.Func.getSearchResult(items, kw); items = search.matched.concat(search.finded); }); - if (options.selectedValues) {//过滤 - var filter = BI.makeObject(options.selectedValues, true); + if (options.selected_values) {//过滤 + var filter = BI.makeObject(options.selected_values, true); items = BI.filter(items, function (i, ob) { return !filter[ob.value]; }); @@ -74,7 +74,7 @@ Demo.MultiSelectCombo = BI.inherit(BI.Widget, { scrolly: false, items: [{ el: this._createMultiSelectCombo(), - right: 10, + right: "50%", top: 10 }] } diff --git a/demo/js/widget/multitree/demo.multi_tree_combo.js b/demo/js/widget/multitree/demo.multi_tree_combo.js new file mode 100644 index 000000000..f1716f8ef --- /dev/null +++ b/demo/js/widget/multitree/demo.multi_tree_combo.js @@ -0,0 +1,41 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.MultiTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + var self = this; + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.multi_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + itemsCreator: function (options, callback) { + console.log(options); + + + callback({ + items: items + }); + }, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.tree.getValue())); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.multi_tree_combo", Demo.MultiTreeCombo); \ No newline at end of file diff --git a/demo/js/widget/numericalinterval/demo.numerical_interval.js b/demo/js/widget/numericalinterval/demo.numerical_interval.js new file mode 100644 index 000000000..b11680a1d --- /dev/null +++ b/demo/js/widget/numericalinterval/demo.numerical_interval.js @@ -0,0 +1,44 @@ +/** + * Created by Dailer on 2017/7/12. + */ +Demo.NumericalInterval = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + + mounted: function () { + var numerical = this.numerical; + var label = this.label; + numerical.on(BI.NumericalInterval.EVENT_CHANGE, function () { + var temp = numerical.getValue(); + var res = "大于" + (temp.closemin ? "等于 " : " ") + temp.min + " 小于" + (temp.closemax ? "等于 " : " ") + temp.max; + label.setValue(res); + }) + }, + + + + + render: function () { + var self = this; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.numerical_interval", + ref: function (_ref) { + self.numerical = _ref; + }, + width: 500 + }, { + type: "bi.label", + ref: function (_ref) { + self.label = _ref; + }, + text: "显示结果" + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.numberical_interval", Demo.NumericalInterval); \ No newline at end of file diff --git a/demo/js/widget/pathchooser/demo.directionpathchooser.js b/demo/js/widget/pathchooser/demo.directionpathchooser.js new file mode 100644 index 000000000..647521fe9 --- /dev/null +++ b/demo/js/widget/pathchooser/demo.directionpathchooser.js @@ -0,0 +1,77 @@ + + + +Demo.DirectionPathChooser = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-direction-path-chooser" + }, + + render: function () { + return { + type: "bi.center_adapt", + items: [ + { + type: "bi.direction_path_chooser", + items: [[{ + "region": "8c4460bc3605685e", + "regionText": "采购订单XXX", + "text": "ID", + "value": "1" + }, { + "region": "0fbd0dc648f41e97", + "regionText": "采购订单", + "text": "学号", + "value": "3" + }, { + "region": "c6d72d6c7e19a667", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }], [{ + "region": "ed013e18cc7c8637", + "regionText": "采购订单XXX", + "text": "ID", + "value": "1" + }, { + "region": "153d75878431f8ee", + "regionText": "A3", + "text": "学号", + "value": "2" + }, { + "region": "3861fb024c7d7825", + "regionText": "采购订单", + "text": "学号", + "value": "3" + }, { + "region": "88e3e5071bd10bc5", + "regionText": "供应商", + "text": "ID", + "value": "4" + }, { + "region": "8476c77ab5c147e0", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }], [{ + "region": "f00f67fbb9fba6fe", + "regionText": "采购订单XXX", + "text": "ID", + "value": "1" + }, { + "region": "1e8badf5d5793408", + "regionText": "A3", + "text": "学号", + "value": "2" + }, { + "region": "de1ebd3d0986a294", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }]] + } + ] + } + } +}) + +BI.shortcut("demo.direction_path_chooser",Demo.DirectionPathChooser); \ No newline at end of file diff --git a/demo/js/widget/demo.pathchooser.js b/demo/js/widget/pathchooser/demo.pathchooser.js similarity index 100% rename from demo/js/widget/demo.pathchooser.js rename to demo/js/widget/pathchooser/demo.pathchooser.js diff --git a/demo/js/widget/quarter/demo.quarter.js b/demo/js/widget/quarter/demo.quarter.js new file mode 100644 index 000000000..bad058e63 --- /dev/null +++ b/demo/js/widget/quarter/demo.quarter.js @@ -0,0 +1,20 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.Quarter = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.quarter_combo", + width: 300 + }] + + } + } +}) + +BI.shortcut("demo.quarter", Demo.Quarter); \ No newline at end of file diff --git a/demo/js/widget/demo.relationview.js b/demo/js/widget/relationview/demo.relationview.js similarity index 100% rename from demo/js/widget/demo.relationview.js rename to demo/js/widget/relationview/demo.relationview.js diff --git a/demo/js/widget/selecttree/demo.multilayer_select_tree_combo.js b/demo/js/widget/selecttree/demo.multilayer_select_tree_combo.js new file mode 100644 index 000000000..a50862225 --- /dev/null +++ b/demo/js/widget/selecttree/demo.multilayer_select_tree_combo.js @@ -0,0 +1,35 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + var self = this; + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.multilayer_select_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + text: "默认值", + items: items, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(self.tree.getValue()[0]); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiLayerSelectTreeCombo); \ No newline at end of file diff --git a/demo/js/widget/selecttree/demo.select_tree_combo.js b/demo/js/widget/selecttree/demo.select_tree_combo.js new file mode 100644 index 000000000..5eeac55a3 --- /dev/null +++ b/demo/js/widget/selecttree/demo.select_tree_combo.js @@ -0,0 +1,182 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.SelectTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + + render: function () { + var self = this; + var items = [{ + id: 1, + text: "第一项", + value: 1, + isParent: true, + title: "第一项" + }, { + id: 2, + text: "第二项", + value: 2, + isParent: true, + title: "第二项" + }, { + id: 3, + text: "第三项", + value: 3, + isParent: true, + open: true, + title: "第三项" + }, { + id: 4, + text: "第四项", + value: 4, + isParent: true, + title: "第四项" + }, { + id: 5, + text: "第五项", + value: 5, + isParent: true, + title: "第五项" + }, { + id: 6, + text: "第六项", + value: 6, + isParent: true, + open: true, + title: "第六项" + }, { + id: 7, + text: "第七项", + value: 7, + isParent: true, + open: true, + title: "第七项" + }, { + id: 11, + pId: 1, + text: "子项1", + value: 11, + title: "子项1" + }, { + id: 12, + pId: 1, + text: "子项2", + value: 12, + title: "子项2" + }, { + id: 13, + pId: 1, + text: "子项3", + value: 13, + title: "子项3" + }, { + id: 21, + pId: 2, + text: "子项1", + value: 21, + title: "子项1" + }, { + id: 22, + pId: 2, + text: "子项2", + value: 22, + title: "子项2" + }, { + id: 31, + pId: 3, + text: "子项1", + value: 31, + title: "子项1" + }, { + id: 32, + pId: 3, + text: "子项2", + value: 32, + title: "子项2" + }, { + id: 33, + pId: 3, + text: "子项3", + value: 33, + title: "子项3" + }, { + id: 41, + pId: 4, + text: "子项1", + value: 41, + title: "子项1" + }, { + id: 42, + pId: 4, + text: "子项2", + value: 42, + title: "子项2" + }, { + id: 43, + pId: 4, + text: "子项3", + value: 43, + title: "子项3" + }, { + id: 51, + pId: 5, + text: "子项1", + value: 51, + title: "子项1" + }, { + id: 52, + pId: 5, + text: "子项2", + value: 52, + title: "子项2" + }, { + id: 61, + pId: 6, + text: "子项1", + value: 61, + title: "子项1" + }, { + id: 62, + pId: 6, + text: "子项2", + value: 62, + title: "子项2" + }, { + id: 71, + pId: 7, + text: "子项1", + value: 71, + title: "子项1" + }, { + id: 72, + pId: 7, + text: "子项2", + value: 72, + title: "子项2" + }]; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.select_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + text: "默认值", + items: items, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(self.tree.getValue()[0]); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.select_tree_combo", Demo.SelectTreeCombo); \ No newline at end of file diff --git a/demo/js/widget/singletree/demo.multilayer_single_tree_combo.js b/demo/js/widget/singletree/demo.multilayer_single_tree_combo.js new file mode 100644 index 000000000..42f06052b --- /dev/null +++ b/demo/js/widget/singletree/demo.multilayer_single_tree_combo.js @@ -0,0 +1,35 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + var self = this; + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.multilayer_single_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + text: "默认值", + items: items, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(self.tree.getValue()[0]); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.multilayer_single_tree_combo", Demo.MultiLayerSingleTreeCombo); \ No newline at end of file diff --git a/demo/js/widget/singletree/demo.single_tree_combo.js b/demo/js/widget/singletree/demo.single_tree_combo.js new file mode 100644 index 000000000..208dec66d --- /dev/null +++ b/demo/js/widget/singletree/demo.single_tree_combo.js @@ -0,0 +1,181 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.SingleTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + + render: function () { + var self = this; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.single_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + text: "默认值", + items: [{ + id: 1, + text: "第一项", + value: 1, + isParent: true, + title: "第一项" + }, { + id: 2, + text: "第二项", + value: 1, + isParent: true, + title: "第二项" + }, { + id: 3, + text: "第三项", + value: 1, + isParent: true, + open: true, + title: "第三项" + }, { + id: 4, + text: "第四项", + value: 1, + isParent: true, + title: "第四项" + }, { + id: 5, + text: "第五项", + value: 1, + isParent: true, + title: "第五项" + }, { + id: 6, + text: "第六项", + value: 1, + isParent: true, + open: true, + title: "第六项" + }, { + id: 7, + text: "第七项", + value: 1, + isParent: true, + open: true, + title: "第七项" + }, { + id: 11, + pId: 1, + text: "子项1", + value: 11, + title: "子项1" + }, { + id: 12, + pId: 1, + text: "子项2", + value: 12, + title: "子项2" + }, { + id: 13, + pId: 1, + text: "子项3", + value: 13, + title: "子项3" + }, { + id: 21, + pId: 2, + text: "子项1", + value: 21, + title: "子项1" + }, { + id: 22, + pId: 2, + text: "子项2", + value: 22, + title: "子项2" + }, { + id: 31, + pId: 3, + text: "子项1", + value: 31, + title: "子项1" + }, { + id: 32, + pId: 3, + text: "子项2", + value: 32, + title: "子项2" + }, { + id: 33, + pId: 3, + text: "子项3", + value: 33, + title: "子项3" + }, { + id: 41, + pId: 4, + text: "子项1", + value: 41, + title: "子项1" + }, { + id: 42, + pId: 4, + text: "子项2", + value: 42, + title: "子项2" + }, { + id: 43, + pId: 4, + text: "子项3", + value: 43, + title: "子项3" + }, { + id: 51, + pId: 5, + text: "子项1", + value: 51, + title: "子项1" + }, { + id: 52, + pId: 5, + text: "子项2", + value: 52, + title: "子项2" + }, { + id: 61, + pId: 6, + text: "子项1", + value: 61, + title: "子项1" + }, { + id: 62, + pId: 6, + text: "子项2", + value: 62, + title: "子项2" + }, { + id: 71, + pId: 7, + text: "子项1", + value: 71, + title: "子项1" + }, { + id: 72, + pId: 7, + text: "子项2", + value: 72, + title: "子项2" + }], + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(self.tree.getValue()[0]); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.single_tree_combo", Demo.SingleTreeCombo); \ No newline at end of file diff --git a/demo/js/widget/table/demo.excel_table.js b/demo/js/widget/table/demo.excel_table.js new file mode 100644 index 000000000..5e518d165 --- /dev/null +++ b/demo/js/widget/table/demo.excel_table.js @@ -0,0 +1,40 @@ +/** + * Created by Dailer on 2017/7/12. + */ +Demo.ExcelTable = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.excel_table", + columnSize: [200,200,200,200,200], + items: [ + [{ + type: "bi.label", + cls: "layout-bg1", + text: "第一行第一列" + }, { + type: "bi.label", + cls: "layout-bg2", + text: "第一行第二列" + }], + [{ + type: "bi.label", + cls: "layout-bg3", + text: "第二行第一列" + }, { + type: "bi.label", + cls: "layout-bg4", + text: "第二行第二列" + }] + ] + }], + width:500 + } + } +}) + +BI.shortcut("demo.excel_table", Demo.ExcelTable); \ No newline at end of file diff --git a/demo/js/widget/timeinterval/demo.time_interval.js b/demo/js/widget/timeinterval/demo.time_interval.js new file mode 100644 index 000000000..d473da5dd --- /dev/null +++ b/demo/js/widget/timeinterval/demo.time_interval.js @@ -0,0 +1,33 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.TimeInterval = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + var self = this; + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.time_interval", + ref: function (_ref) { + self.interval = _ref; + }, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.interval.getValue())); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.time_interval", Demo.TimeInterval); \ No newline at end of file diff --git a/demo/js/widget/tree/demo.multilayer_select_tree_combo.js b/demo/js/widget/tree/demo.multilayer_select_tree_combo.js deleted file mode 100644 index 4968bb7b1..000000000 --- a/demo/js/widget/tree/demo.multilayer_select_tree_combo.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Created by User on 2017/3/22. - */ -Demo.MultiSelectCombo = BI.inherit(BI.Widget, { - props: {}, - - render: function (vessel) { - var TREEWITHCHILDREN = [{ - id: -1, value: "根目录", text: "根目录", children: [ - { - id: 1, value: "第一级目录1", text: "第一级目录1", children: [ - {id: 11, value: "第二级文件1", text: "第二级文件1"}, - { - id: 12, value: "第二级目录2", text: "第二级目录2", children: [ - { - id: 121, value: "第三级目录1", text: "第三级目录1", children: [ - { - id: 1211, value: "第四级目录1", text: "第四级目录1", children: [ - {id: 12111, value: "第五级文件1", text: "第五级文件1"} - ] - } - ] - }, - {id: 122, value: "第三级文件1", text: "第三级文件1"} - ] - } - ] - }, - { - id: 2, value: "第一级目录2", text: "第一级目录2", children: [ - { - id: 21, value: "第二级目录3", text: "第二级目录3", children: [ - { - id: 211, value: "第三级目录2", text: "第三级目录2", children: [ - {id: 2111, value: "第四级文件1", text: "第四级文件1"} - ] - }, - {id: 212, value: "第三级文件2", text: "第三级文件2"} - ] - }, - {id: 22, value: "第二级文件2", text: "第二级文件2"} - ] - } - ] - }]; - var items = BI.deepClone(TREEWITHCHILDREN); - var combo = BI.createWidget({ - type: "bi.multilayer_select_tree_combo", - }); - - combo.populate(items); - return { - type: "bi.vertical", - items: [combo, { - type: "bi.button", - width: 100, - text: "getValue", - handler: function () { - BI.Msg.alert("", JSON.stringify(combo.getValue())); - } - }], - vgap: 100 - } - } -}); -BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiSelectCombo); \ No newline at end of file diff --git a/demo/js/widget/tree/demo.switch_tree.js b/demo/js/widget/tree/demo.switch_tree.js new file mode 100644 index 000000000..0e7a1788d --- /dev/null +++ b/demo/js/widget/tree/demo.switch_tree.js @@ -0,0 +1,24 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.SwitchTree = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.switch_tree", + items: items + },{ + type:"bi.button", + text:"getValue" + }] + } + } +}) + +BI.shortcut("demo.switch_tree", Demo.SwitchTree); \ No newline at end of file diff --git a/demo/js/widget/year/demo.year.js b/demo/js/widget/year/demo.year.js new file mode 100644 index 000000000..810b224b9 --- /dev/null +++ b/demo/js/widget/year/demo.year.js @@ -0,0 +1,19 @@ +/** + * Created by Dailer on 2017/7/11. + */ +Demo.Year = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.year_combo", + width: 300 + }] + } + } +}) + +BI.shortcut("demo.year", Demo.Year); \ No newline at end of file diff --git a/demo/js/widget/yearmonth/demo.year_month_combo.js b/demo/js/widget/yearmonth/demo.year_month_combo.js new file mode 100644 index 000000000..02ab8af65 --- /dev/null +++ b/demo/js/widget/yearmonth/demo.year_month_combo.js @@ -0,0 +1,32 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.YearMonthCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + + var self = this; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.year_month_combo", + ref: function (_ref) { + self.widget = _ref; + }, + width: 300 + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.widget.getValue())) + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.year_month_combo", Demo.YearMonthCombo); \ No newline at end of file diff --git a/demo/js/widget/yearquarter/demo.year_quarter_combo.js b/demo/js/widget/yearquarter/demo.year_quarter_combo.js new file mode 100644 index 000000000..ddd9cccf2 --- /dev/null +++ b/demo/js/widget/yearquarter/demo.year_quarter_combo.js @@ -0,0 +1,33 @@ +/** + * Created by Dailer on 2017/7/13. + */ +Demo.YearQuarterCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + var self=this; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.year_quarter_combo", + width: 300, + ref:function(_ref){ + self.widget=_ref; + }, + yearBehaviors: {}, + quarterBehaviors: {}, + }, { + type: "bi.button", + text: "getValue", + handler:function(){ + BI.Msg.toast(JSON.stringify(self.widget.getValue())) + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.year_quarter_combo", Demo.YearQuarterCombo); \ No newline at end of file diff --git a/demo/less/main.less b/demo/less/main.less index 662c65ed7..132ee48f1 100644 --- a/demo/less/main.less +++ b/demo/less/main.less @@ -1,5 +1,4 @@ @import "index"; - .layout-bg-white { background-color: #ffffff; } @@ -60,4 +59,8 @@ body { .bi-theme-dark body { background-color: @color-bi-background-normal-theme-dark; -} \ No newline at end of file +} + +.demo-editor { + border: 1px solid rgb(204, 204, 204); +} diff --git a/docs/case.js b/docs/case.js index ca2452851..1f5a3faf1 100644 --- a/docs/case.js +++ b/docs/case.js @@ -12033,6 +12033,19 @@ BI.DisplayTree = BI.inherit(BI.TreeView, { return setting; }, + _dealWidthNodes: function (nodes) { + nodes = BI.DisplayTree.superclass._dealWidthNodes.apply(this, arguments); + var self = this, o = this.options; + BI.each(nodes, function (i, node) { + if (node.count > 0) { + node.text = node.value + "(" + BI.i18nText("BI-Basic_Altogether") + node.count + BI.i18nText("BI-Basic_Count") + ")"; + } else { + node.text = node.value; + } + }); + return nodes; + }, + initTree: function (nodes, setting) { var setting = setting || this._configSetting(); this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes); diff --git a/docs/core.css b/docs/core.css index 151794401..b09047d83 100644 --- a/docs/core.css +++ b/docs/core.css @@ -3900,7 +3900,7 @@ i { .bi-list-item-none:hover, .bi-list-item-none.hover { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-list-item-none:hover .bi-input, .bi-list-item-none.hover .bi-input { @@ -3913,7 +3913,7 @@ i { .bi-list-item-none:active, .bi-list-item-none.active { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-list-item-none:active .bi-input, .bi-list-item-none.active .bi-input { @@ -3951,7 +3951,7 @@ i { .bi-theme-dark .bi-list-item-none:hover, .bi-theme-dark .bi-list-item-none.hover { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-theme-dark .bi-list-item-none:hover .bi-input, .bi-theme-dark .bi-list-item-none.hover .bi-input { @@ -3964,7 +3964,7 @@ i { .bi-theme-dark .bi-list-item-none:active, .bi-theme-dark .bi-list-item-none.active { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-theme-dark .bi-list-item-none:active .bi-input, .bi-theme-dark .bi-list-item-none.active .bi-input { diff --git a/docs/demo.css b/docs/demo.css index 9b3f8c0bc..71b16e78d 100644 --- a/docs/demo.css +++ b/docs/demo.css @@ -48,6 +48,9 @@ body { .bi-theme-dark body { background-color: #191B2B; } +.demo-editor { + border: 1px solid #cccccc; +} .demo-north { background-color: #3c8dbc; } diff --git a/docs/demo.js b/docs/demo.js index e214aa122..79a6bf368 100644 --- a/docs/demo.js +++ b/docs/demo.js @@ -2917,7 +2917,7 @@ BI.shortcut("demo.value_chooser_combo", Demo.ValueChooserCombo);Demo.ValueChoose BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.BASE_CONFIG = [{ id: 2, text: "基础控件", - open: true + open: false }, { pId: 2, text: "bi.label", @@ -3033,7 +3033,7 @@ BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.BASE_CONFIG = }];Demo.CASE_CONFIG = [{ id: 3, text: "实例控件", - open: true, + open: false }, { pId: 3, id: 301, @@ -3347,6 +3347,7 @@ Demo.COMPONENT_CONFIG = [{ text: "pane", value: "demo.pane" }];Demo.WIDGET_CONFIG = [{ +<<<<<<< HEAD id: 4, text: "详细控件" }, { @@ -3398,6 +3399,260 @@ Demo.COMPONENT_CONFIG = [{ text: "bi.custom_date_time", value: "demo.custom_date_time" }];Demo.Func = BI.inherit(BI.Widget, { +======= + id: 4, + text: "详细控件", + open: true + }, { + id: 400, + pId: 4, + text: "tree" + }, { + pId: 400, + text: "bi.multi_tree_combo", + value: "demo.multi_tree_combo" + }, { + id: 401, + pId: 4, + text: "table" + }, { + pId: 401, + text: "bi.preview_table", + value: "demo.preview_table" + }, { + pId: 401, + text: "bi.responsive_table", + value: "demo.responsive_table" + }, { + pId: 401, + text: "bi.excel_table", + value: "demo.excel_table" + }, { + pId: 4, + id: 402, + text: "年份控件", + open: false + }, { + pId: 402, + text: "bi.year_combo", + value: "demo.year" + }, { + pId: 4, + id: 403, + text: "月份控件", + open: false + }, { + pId: 403, + text: "bi.month_combo", + value: "demo.month" + }, { + pId: 4, + id: 404, + text: "季度控件", + open: false + }, { + pId: 404, + text: "bi.quarter_combo", + value: "demo.quarter" + }, { + pId: 4, + id: 405, + text: "下拉列表", + open: false + }, { + pId: 405, + text: "bi.down_list_combo", + value: "demo.down_list" + }, { + pId: 4, + id: 406, + text: "文本框控件", + open: false + }, { + pId: 406, + text: "bi.text_editor", + value: "demo.text_editor" + }, { + pId: 406, + text: "bi.search_editor", + value: "demo.search_editor" + }, { + pId: 406, + text: "bi.sign_editor", + value: "demo.sign_editor" + }, { + pId: 406, + text: "bi.sign_initial_editor", + value: "demo.sign_initial_editor" + }, { + pId: 406, + text: "bi.sign_style_editor", + value: "demo.sign_style_editor" + }, { + pId: 406, + text: "bi.state_editor", + value: "demo.state_editor" + }, { + pId: 406, + text: "bi.clear_editor", + value: "demo.clear_editor" + }, { + pId: 406, + text: "bi.record_editor", + value: "demo.record_editor" + }, { + pId: 406, + text: "bi.shelter_editor", + value: "demo.shelter_editor" + }, + { + pId: 4, + id: 407, + text: "下拉框控件", + open: false + }, { + pId: 407, + text: "bi.text_value_combo", + value: "demo.text_value_combo" + }, { + pId: 407, + text: "bi.text_value_check_combo", + value: "demo.text_value_check_combo" + }, { + pId: 407, + text: "bi.text_value_down_list_combo", + value: "demo.text_value_down_list_combo" + }, { + pId: 407, + text: "bi.static_combo", + value: "demo.static_combo" + }, { + pId: 407, + text: "bi.icon_combo", + value: "demo.icon_combo" + }, { + pId: 407, + text: "bi.formula_combo", + value: "demo.formula_combo" + }, { + pId: 4, + id: 408, + text: "选择字段列表", + open: false + }, { + pId: 408, + text: "bi.placeholder" + }, { + pId: 4, + id: 409, + text: "公式编辑器", + open: false + }, { + pId: 409, + text: "bi.placeholder" + }, { + pId: 4, + id: 410, + text: "数值区间控件" + }, { + pId: 410, + text: "bi.numerical_interval", + value: "demo.numberical_interval" + }, { + pId: 4, + id: 411, + text: "下拉复选框有确定按钮" + }, { + pId: 411, + text: "bi.multi_select_combo", + value: "demo.multi_select_combo" + }, { + pId: 4, + id: 412, + text: "简单日期控件" + }, { + pId: 412, + text: "bi.date_combo", + value: "demo.date" + }, { + pId: 412, + text: "bi.date_pane_widget", + value: "demo.date_pane_widget" + }, { + pId: 412, + text: "bi.year_month_combo", + value: "demo.year_month_combo" + },{ + pId: 412, + text: "bi.year_quarter_combo", + value: "demo.year_quarter_combo" + },{ + pId: 4, + id: 413, + text: "简单下拉树" + }, { + pId: 413, + text: "bi.single_tree_combo", + value: "demo.single_tree_combo" + }, { + pId: 413, + text: "bi.multilayer_single_tree_combo", + value: "demo.multilayer_single_tree_combo" + }, { + pId: 4, + id: 414, + text: "可选下拉树" + }, { + pId: 414, + text: "bi.select_tree_combo", + value: "demo.select_tree_combo" + }, { + pId: 414, + text: "bi.multilayer_select_tree_combo", + value: "demo.multilayer_select_tree_combo" + }, { + pId: 4, + id: 415, + text: "路径选择" + }, { + pId: 415, + text: "bi.path_chooser", + value: "demo.path_chooser" + }, { + pId: 415, + text: "bi.direction_path_chooser", + value: "demo.direction_path_chooser" + }, { + pId: 4, + id: 416, + text: "关联视图" + }, { + pId: 416, + text: "bi.relation_view", + value: "demo.relation_view" + }, { + pId: 4, + id: 417, + text: "布局" + }, { + pId: 417, + text: "bi.adaptive_arrangement", + value: "demo.adaptive_arrangement" + }, { + pId: 417, + text: "bi.interactive_arrangement", + value: "demo.interactive_arrangement" + }, { + pId: 4, + id: 418, + text: "提示对话框" + }, { + pId: 418, + text: "bi.dialog", + value: "demo.dialog" + } +];Demo.Func = BI.inherit(BI.Widget, { +>>>>>>> 3903ca444e161ac208f69ba22c0a3136d7a0fa81 props: { baseCls: "demo-func" }, @@ -5960,6 +6215,7 @@ BI.shortcut("demo.preview", Demo.Preview);Demo.West = BI.inherit(BI.Widget, { } }); Demo.West.EVENT_VALUE_CHANGE = "EVENT_VALUE_CHANGE"; +<<<<<<< HEAD BI.shortcut("demo.west", Demo.West);/** * Created by Urthur on 2017/7/18. */ @@ -5973,6 +6229,129 @@ Demo.CustomDateTime = BI.inherit(BI.Widget, { } }); BI.shortcut("demo.custom_date_time", Demo.CustomDateTime);/** +======= +BI.shortcut("demo.west", Demo.West);Demo.AdaptiveArrangement = BI.inherit(BI.Widget, { + + _createItem: function () { + var self = this; + var id = BI.UUID(); + var item = BI.createWidget({ + type: "bi.text_button", + id: id, + cls: "layout-bg" + BI.random(1, 8), + handler: function () { + self.arrangement.deleteRegion(id); + } + }); + item.setValue(item.attr("id")); + return item; + }, + + render: function () { + var self = this; + this.arrangement = BI.createWidget({ + type: "bi.adaptive_arrangement", + layoutType: BI.Arrangement.LAYOUT_TYPE.ADAPTIVE, + cls: "mvc-border", + width: 800, + height: 400, + items: [] + }); + var drag = BI.createWidget({ + type: "bi.label", + cls: "mvc-border", + width: 100, + height: 25, + text: "drag me" + }); + + // drag.element.draggable && + drag.element.draggable({ + revert: true, + cursorAt: { + left: 0, + top: 0 + }, + drag: function (e, ui) { + self.arrangement.setPosition({ + left: ui.position.left, + top: ui.position.top + }, { + width: 300, + height: 200 + }) + }, + stop: function (e, ui) { + self.arrangement.addRegion({ + el: self._createItem() + }); + }, + helper: function (e) { + var helper = self.arrangement.getHelper(); + return helper.element; + } + }); + + BI.createWidget({ + type: "bi.absolute", + items: [{ + el: drag, + left: 30, + top: 450 + }, { + el: this.arrangement, + left: 30, + top: 30 + }, { + el: { + type: "bi.button", + text: "回撤", + height: 25, + handler: function () { + //self.arrangement.revoke(); + } + }, + left: 130, + top: 450 + }, { + el: { + type: "bi.button", + text: "getAllRegions", + height: 25, + handler: function () { + var items = []; + BI.each(self.arrangement.getAllRegions(), function (i, region) { + items.push({ + id: region.id, + left: region.left, + top: region.top, + width: region.width, + height: region.height + }); + }); + BI.Msg.toast(JSON.stringify(items)); + } + }, + left: 230, + top: 450 + }, { + el: { + type: "bi.button", + text: "relayout", + height: 25, + handler: function () { + self.arrangement.relayout(); + } + }, + left: 330, + top: 450 + }] + }); + } +}); + +BI.shortcut("demo.adaptive_arrangement", Demo.AdaptiveArrangement);/** +>>>>>>> 3903ca444e161ac208f69ba22c0a3136d7a0fa81 * Created by User on 2017/3/22. */ Demo.RelationView = BI.inherit(BI.Widget, { @@ -5985,122 +6364,1567 @@ Demo.RelationView = BI.inherit(BI.Widget, { } }); BI.shortcut("demo.interactive_arrangement", Demo.RelationView);/** - * Created by User on 2017/3/22. + * Created by Dailer on 2017/7/12. */ -Demo.MultiSelectCombo = BI.inherit(BI.Widget, { +Demo.FormulaCombo = BI.inherit(BI.Widget, { props: { - baseCls: "demo-multi-select-combo" + baseCls: "" }, - _createMultiSelectCombo: function () { + render: function () { + var self = this; - var widget = BI.createWidget({ - type: 'bi.multi_select_combo', - itemsCreator: BI.bind(this._itemsCreator, this), - width: 200 - }); - widget.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () { - BI.Msg.toast(JSON.stringify(this.getValue())); - }); - return widget; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.formula_combo", + fieldItems: [{ + text: "A", + value: "A", + fieldType: 16 + }], + width: 200, + height: 30 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.formula_combo", Demo.FormulaCombo);/** + * Created by Dailer on 2017/7/12. + */ +Demo.IconCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" }, - _getItemsByTimes: function (items, times) { - var res = []; - for (var i = (times - 1) * 3; items[i] && i < times * 3; i++) { - res.push(items[i]); + render: function () { + + var self = this; + + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.icon_combo", + ref:function(_ref){ + self.refs=_ref; + }, + // iconClass: "pull-down-ha-font", + items: [{ + value: "第一项", + iconClass: "delete-font" + }, { + value: "第二项", + iconClass: "rename-font" + }, { + value: "第三项", + iconClass: "move-font" + }] + }], + vgap: 20 } - return res; + } +}) + +BI.shortcut("demo.icon_combo", Demo.IconCombo);/** + * Created by Dailer on 2017/7/11. + */ +Demo.StaticCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" }, - _hasNextByTimes: function (items, times) { - return times * 3 < items.length; + + beforeMounted: function () { + this.refs.setValue(2); }, - _itemsCreator: function (options, callback) { + render: function () { + var self = this; - var items = Demo.CONSTANTS.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; + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.static_combo", + text: "Value 不变", + width: 300, + ref: function (_ref) { + self.refs = _ref; + }, + items: [ + { + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + } + ] + }], + vgap: 20 } - if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { - callback({count: items.length}); - return; + } +}) + +BI.shortcut("demo.static_combo", Demo.StaticCombo);/** + * Created by Dailer on 2017/7/11. + */ +Demo.TextValueCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.text_value_combo", + text: "天气热死了", + width: 300, + items: [{ + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + },{ + type: "bi.text_value_check_combo", + text: "天气热死了", + width: 300, + items: [{ + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + },{ + type: "bi.text_value_combo", + text: "天气热死了", + width: 300, + items: [{ + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + }], + vgap: 20 } - BI.delay(function () { - callback({ - items: self._getItemsByTimes(items, options.times), - hasNext: self._hasNextByTimes(items, options.times) - }); - }, 1000); + } +}) + +BI.shortcut("demo.text_value_combo", Demo.TextValueCombo);/** + * Created by Dailer on 2017/7/11. + */ +Demo.TextValueDownListCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + + beforeMounted:function(){ + this.refs.setValue(2); }, render: function () { + + var self = this; + return { - type: 'bi.absolute', - scrolly: false, + type: "bi.horizontal_auto", items: [{ - el: this._createMultiSelectCombo(), - right: 10, - top: 10 - }] + type: "bi.label", + cls: "layout-bg2", + text: "分组+二级", + width: 300 + }, { + type: "bi.text_value_down_list_combo", + text: "天气热死了", + width: 300, + ref: function (_ref) { + self.refs = _ref; + }, + items: [ + [{ + el: { + text: "MVC-1", + value: 1 + }, + children: [{ + text: "MVC-1-1", + value: 11 + }] + }], + [{ + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + ] + }], + vgap: 20 } } -}); -BI.shortcut("demo.multi_select_combo", Demo.MultiSelectCombo);/** - * Created by User on 2017/3/22. +}) + +BI.shortcut("demo.text_value_down_list_combo", Demo.TextValueDownListCombo);/** + * Created by Dailer on 2017/7/11. */ -Demo.PathChooser = BI.inherit(BI.Widget, { +Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { props: { - baseCls: "demo-path-chooser" + baseCls: "" }, render: function () { - var pathchooser = BI.createWidget({ - type: "bi.path_chooser", - width: 800, - height: 400, - items: // [ - // [{region: "区域X", value: "X1"}, - // {region: "区域Q", value: "Q"}, - // {region: "区域A", value: "A"}, - // {region: "区域B", value: "B"}, - // {region: "区域D", value: "D"}, - // {region: "区域E", value: "E"}, - // {region: "区域G", value: "G"}, - // {region: "区域I", value: "I"}, - // {region: "区域J", value: "J"}], - // [{region: "区域X", value: "X"}, - // {region: "区域Q", value: "Q"}, - // {region: "区域A", value: "A"}, - // {region: "区域B", value: "B"}, - // {region: "区域C", value: "C"}, - // {region: "区域D", value: "D"}, - // {region: "区域E", value: "E"}, - // {region: "区域G", value: "G"}, - // {region: "区域I", value: "I"}, - // {region: "区域J", value: "J"}], - // [{region: "区域X", value: "X"}, - // //{region: "区域Q", value: "Q"}, - // {region: "区域A", value: "A"}, + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.text_value_check_combo", + text: "天气热死了", + width: 300, + items: [{ + text: "MVC-1", + value: 1 + }, { + text: "MVC-2", + value: 2 + }, { + text: "MVC-3", + value: 3 + }] + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.text_value_check_combo", Demo.TextValueCheckCombo);/** + * Created by Dailer on 2017/7/11. + */ +Demo.Date = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-date" + }, + + _init: function () { + Demo.Date.superclass._init.apply(this, arguments); + }, + + render: function () { + + return { + type: "bi.horizontal_auto", + vgap: 10, + items: [{ + type: "bi.date_combo", + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + height: 50, + width: 300 + }] + } + } +}) + +BI.shortcut("demo.date", Demo.Date);Demo.DatePane = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-datepane" + }, + render: function () { + + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.vertical", + vgap: 10, + items: [{ + type: "bi.label", + cls: "layout-bg2", + text: "bi.date_pane_widget" + }, { + type: "bi.date_pane_widget", + selectedTime: { + year: 2017, + month: 12, + day: 11 + }, + height:300 + }, + { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast("date" + JSON.stringify(datepane.getValue())); + } + } + ], + width: "50%" + }] + } + } +}) + +BI.shortcut("demo.date_pane_widget", Demo.DatePane);Demo.DialogView = BI.inherit(BI.Widget, { + + render: function () { + var items = [{ + el: { + type: 'bi.button', + text: '弹出对话框', + level: 'common', + height: 30 + } + }]; + BI.each(items, function (i, item) { + item.el.handler = function () { + BI.Msg.alert('提示', "这是一段可以换行的文字,为了使它换行我要多写几个字,但是我又凑不够这么多的字,万般焦急下,只能随便写写"); + } + }); + + return { + type: "bi.left", + vgap: 200, + hgap: 20, + items: items + } + } +}); + +BI.shortcut("demo.dialog", Demo.DialogView);Demo.Downlist = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-downlist" + }, + + mounted: function () { + var downlist = this.downlist; + var label = this.label; + downlist.on(BI.DownListCombo.EVENT_CHANGE, function (value, fatherValue) { + label.setValue(JSON.stringify(downlist.getValue())); + }); + + this.downlist.on(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { + label.setValue(JSON.stringify(downlist.getValue())); + }); + }, + + + render: function () { + self = this; + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.down_list_combo", + ref: function (_ref) { + self.downlist = _ref; + }, + cls:"layout-bg3", + height: 30, + width: 100, + items: [ + [{ + el: { + text: "column 1111", + iconCls1: "check-mark-e-font", + value: 11 + }, + children: [{ + text: "column 1.1", + value: 21, + cls: "dot-e-font", + selected: true + }, { + text: "column 1.222222222222222222222222222222222222", + cls: "dot-e-font", + value: 22, + }] + }], + [{ + el: { + type: "bi.icon_text_icon_item", + text: "column 2", + iconCls1: "chart-type-e-font", + cls: "dot-e-font", + value: 12 + }, + disabled: true, + children: [{ + type: "bi.icon_text_item", + cls: "dot-e-font", + height: 25, + text: "column 2.1", + value: 11 + }, { + text: "column 2.2", + value: 12, + cls: "dot-e-font" + }] + }], + [{ + text: "column 8", + value: 18, + cls: "dot-e-font", + selected: true + }, + { + + text: "column 9", + cls: "dot-e-font", + value: 19 + } + ], + [{ + text: "column 10", + value: 20, + cls: "dot-e-font", + selected: true + }, + { + + text: "column 11", + cls: "dot-e-font", + value: 21 + }, + { + + text: "column 12", + cls: "dot-e-font", + value: 22 + }, + { + + text: "column 13", + cls: "dot-e-font", + value: 23 + }, + { + + text: "column 14", + cls: "dot-e-font", + value: 24 + }, + { + + text: "column 15", + cls: "dot-e-font", + value: 23 + } + ] + + ] + }, { + type: "bi.label", + text: "显示选择值", + width:500, + cls:"layout-bg4", + ref: function (_ref) { + self.label = _ref; + } + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.down_list", Demo.Downlist);/** + * Created by Dailer on 2017/7/11. + */ +Demo.AdaptEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + + + //这东西好奇怪,不支持设置宽度,那么渲染出来宽度几乎没有,无奈之下只能假装给他个默认值了 + beforeMounted: function () { + this.refs.setValue("Winter is coming !") + }, + + render: function () { + var self = this; + var editor = BI.createWidget({ + type: "bi.adapt_editor", + cls: "layout-bg5", + ref: function (_ref) { + self.refs = _ref; + } + }) + + var text=["You know nothing! Jon Snow","A Lannister always pays his debts.","Power is a curious thing."] + + return { + type: "bi.horizontal_auto", + items: [{ + el: editor + }, { + type: "bi.button", + text: "为了展示长度真的是可变的,每点一下就换一行字", + handler: function () { + var temp=text.shift(); + editor.setValue(temp); + text.push(temp); + } + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.adapt_editor", Demo.AdaptEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.ClearEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.clear_editor", + cls: "bi-border", + width: 300, + watermark: "这个是带清除按钮的" + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.clear_editor", Demo.ClearEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.RecordEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.record_editor", + cls: "bi-border", + width: 300, + watermark: "这个是可以记录输入的" + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.record_editor", Demo.RecordEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.SearchEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.search_editor", + width: 300, + watermark:"添加合法性判断", + errorText: "长度必须大于4", + validationChecker:function(){ + return this.getValue().length > 4 ? true : false + } + },{ + type: "bi.small_search_editor", + width: 300, + watermark:"这个是 small,小一号" + }], + vgap:20 + } + } +}) + +BI.shortcut("demo.search_editor", Demo.SearchEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.ClearEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + var editor; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.shelter_editor", + cls: "bi-border", + ref:function(_ref){ + editor=_ref; + }, + width: 300, + watermark: "这个是带标记的" + },{ + type:"bi.button", + text:"setValue", + width:300, + handler:function(){ + editor.setValue("凛冬将至"); + } + },{ + type:"bi.button", + text:"doHighLight", + width:300, + handler:function(){ + editor.doHighLight(); + console.log(editor.getState()); + } + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.shelter_editor", Demo.ClearEditor);/** + * Created by Dailer on 2017/7/14. + */ +Demo.SignEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.sign_editor", + // cls:"layout-bg5", + value: "123", + text: "456", + width: 300 + }], + vgap: 20 + + } + } +}) + +BI.shortcut("demo.sign_editor", Demo.SignEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.SignInitialEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.sign_initial_editor", + cls:"layout-bg5", + value:"123", + text:"456", + width: 300 + }], + vgap:20 + + } + } +}) + +BI.shortcut("demo.sign_initial_editor", Demo.SignInitialEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.SignStyleEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.sign_style_editor", + cls:"layout-bg5", + value:"12313", + width: 300 + }], + vgap:20 + } + } +}) + +BI.shortcut("demo.sign_style_editor", Demo.SignStyleEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.StateEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.state_editor", + cls:"bi-border", + value:"123", + text:"456", + width: 300 + }], + vgap:20 + + } + } +}) + +BI.shortcut("demo.state_editor", Demo.StateEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.TextEditor = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.text_editor", + watermark:"这是水印,watermark", + width: 300 + },{ + type: "bi.text_editor", + watermark:"这个不予许空", + allowBlank: false, + errorText: "非空!", + width: 300 + }], + vgap:20 + + } + } +}) + +BI.shortcut("demo.text_editor", Demo.TextEditor);/** + * Created by Dailer on 2017/7/11. + */ +Demo.Month = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.month_combo", + width: 300 + }] + + } + } +}) + +BI.shortcut("demo.month", Demo.Month);/** + * Created by Urthur on 2017/7/14. + */ +BI.MultiDateTimeCombo = BI.inherit(BI.Single, { + constants: { + popupHeight: 290, + popupWidth: 270, + comboAdjustHeight: 1, + border: 1, + DATE_MIN_VALUE: "1900-01-01", + DATE_MAX_VALUE: "2099-12-31" + }, + _defaultConfig: function () { + return BI.extend(BI.MultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-date-time-combo bi-border', + height: 24 + }); + }, + _init: function () { + BI.MultiDateTimeCombo.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + var date = new Date(); + this.storeValue = { + value: { + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate(), + hour: date.getHours(), + minute: date.getMinutes(), + second: date.getSeconds() + } + }; + this.trigger = BI.createWidget({ + type: 'bi.date_time_trigger', + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE + }); + + this.popup = BI.createWidget({ + type: "bi.multi_date_time_popup", + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE + }); + self.setValue(this.storeValue); + + this.popup.on(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () { + self.combo.hideView(); + self.fireEvent(BI.MultiDateTimeCombo.EVENT_CANCEL); + }); + this.popup.on(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiDateTimeCombo.EVENT_CONFIRM); + }); + this.popup.on(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + }); + this.combo = BI.createWidget({ + type: 'bi.combo', + toggle: false, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: this.popup, + maxHeight: this.constants.popupHeight, + width: this.constants.popupWidth, + stopPropagation: false + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW); + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + cls: "bi-trigger-date-button chart-date-normal-font bi-border-right", + width: 30, + height: 24 + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + type: "bi.absolute", + items: [{ + el: this.combo, + top: 0, + left: 0, + right: 0, + bottom: 0 + }, { + el: triggerBtn, + top: 0, + left: 0 + }] + }] + }) + }, + + setValue: function (v) { + this.storeValue = v; + this.popup.setValue(v); + this.trigger.setValue(v); + }, + getValue: function () { + return this.storeValue; + } +}); + +BI.MultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL"; +BI.MultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.multi_date_time_combo', BI.MultiDateTimeCombo); +/** + * Created by Urthur on 2017/7/14. + */ +BI.CustomMultiDateTimeCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CustomMultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-custom-multi-date-time-combo" + }) + }, + + _init: function () { + BI.CustomMultiDateTimeCombo.superclass._init.apply(this, arguments); + var self = this; + this.multiDateTime = BI.createWidget({ + type: "bi.multi_date_time_combo", + element: this + }); + this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CANCEL, function () { + self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CANCEL); + }); + + this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CONFIRM); + }); + }, + + getValue: function () { + return this.multiDateTime.getValue(); + }, + + setValue: function (v) { + this.multiDateTime.setValue(v); + } +}); +BI.CustomMultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.CustomMultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL"; +BI.CustomMultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.custom_multi_date_time_combo", BI.CustomMultiDateTimeCombo); +/** + * Created by Urthur on 2017/7/14. + */ +BI.MultiDateTimePopup = BI.inherit(BI.Widget, { + constants: { + tabHeight: 30, + tabWidth: 42, + titleHeight: 27, + itemHeight: 30, + triggerHeight: 24, + buttonWidth: 90, + buttonHeight: 25, + popupHeight: 290, + popupWidth: 270, + comboAdjustHeight: 1, + lgap: 2, + border: 1 + }, + _defaultConfig: function () { + return BI.extend(BI.MultiDateTimePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-date-time-popup', + width: 268, + height: 290 + }); + }, + _init: function () { + BI.MultiDateTimePopup.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + this.cancelButton = BI.createWidget({ + type: 'bi.text_button', + forceCenter: true, + cls: 'bi-multidate-popup-button bi-border-top bi-border-right', + shadow: true, + text: BI.i18nText("BI-Basic_Cancel") + }); + this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE); + }); + + this.okButton = BI.createWidget({ + type: "bi.text_button", + forceCenter: true, + cls: 'bi-multidate-popup-button bi-border-top', + shadow: true, + text: BI.i18nText("BI-Basic_OK") + }); + this.okButton.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE); + }); + + this.dateCombo = BI.createWidget({ + type: "bi.date_calendar_popup", + min: self.options.min, + max: self.options.max + }); + self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE); + }); + + this.dateSelect = BI.createWidget({ + type: "bi.horizontal", + cls: "bi-border-top", + items: [{ + type: "bi.label", + text: BI.i18nText("BI-Basic_Time"), + width: 45 + },{ + type: "bi.multi_date_time_select", + max: 23, + min: 0, + width: 60, + height: 30, + ref: function (_ref) { + self.hour = _ref; + self.hour.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () { + self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE); + }); + } + },{ + type: "bi.label", + text: ":", + width: 15 + },{ + type: "bi.multi_date_time_select", + max: 59, + min: 0, + width: 60, + height: 30, + ref: function (_ref) { + self.minute = _ref; + self.minute.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () { + self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE); + }); + } + },{ + type: "bi.label", + text: ":", + width: 15 + },{ + type: "bi.multi_date_time_select", + max: 59, + min: 0, + width: 60, + height: 30, + ref: function (_ref) { + self.second = _ref; + self.second.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () { + self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE); + }); + } + }] + }); + + this.dateButton = BI.createWidget({ + type: "bi.grid", + items: [[this.cancelButton, this.okButton]] + }); + BI.createWidget({ + element: this, + type: "bi.vtape", + items: [{ + el: this.dateCombo + }, { + el: this.dateSelect, + height: 50 + },{ + el: this.dateButton, + height: 30 + }] + }); + }, + + setValue: function (v) { + var value, date; + if (BI.isNotNull(v)) { + value = v.value; + if(BI.isNull(value)){ + date = new Date(); + this.dateCombo.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + this.hour.setValue(date.getHours()); + this.minute.setValue(date.getMinutes()); + this.second.setValue(date.getSeconds()); + } else { + this.dateCombo.setValue({ + year: value.year, + month: value.month, + day: value.day + }); + this.hour.setValue(value.hour); + this.minute.setValue(value.minute); + this.second.setValue(value.second); + } + } + }, + + getValue: function () { + return { + value: { + year: this.dateCombo.getValue().year, + month: this.dateCombo.getValue().month, + day: this.dateCombo.getValue().day, + hour: this.hour.getValue(), + minute: this.minute.getValue(), + second: this.second.getValue() + } + } + } +}); +BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE"; +BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; +BI.shortcut('bi.multi_date_time_popup', BI.MultiDateTimePopup); + +/** + * Created by Urthur on 2017/7/14. + */ +BI.MultiDateTimeSelect = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiDateTimeSelect.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-date-time-select bi-border", + max: 23, + min: 0 + }) + }, + + _init: function () { + BI.MultiDateTimeSelect.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + value: this._alertInEditorValue(o.min), + errorText: BI.i18nText("BI-Please_Input_Natural_Number"), + validationChecker: function(v){ + return BI.isNaturalNumber(v); + } + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){ + self._finetuning(0); + self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(1); + self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM); + }); + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "column-next-page-h-font bottom-button bi-border-left" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(-1); + self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM); + }); + this._finetuning(0); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [this.editor, { + el: { + type: "bi.grid", + columns: 1, + rows: 2, + items: [{ + column: 0, + row: 0, + el: this.topBtn + }, { + column: 0, + row: 1, + el: this.bottomBtn + }] + }, + width: 30 + }] + }); + }, + + _alertOutEditorValue: function(v){ + if (v > this.options.max){ + v = this.options.min; + } + if (v < this.options.min){ + v = this.options.max + } + return BI.parseInt(v); + }, + + _alertInEditorValue: function(v){ + if (v > this.options.max){ + v = this.options.min; + } + if (v < this.options.min){ + v = this.options.max; + } + v = v < 10 ? "0" + v : v; + return v; + }, + + _finetuning: function(add){ + var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); + this.editor.setValue(this._alertInEditorValue(v + add)); + }, + + getValue: function () { + var v = this.editor.getValue(); + return this._alertOutEditorValue(v); + }, + + setValue: function (v) { + this.editor.setValue(this._alertInEditorValue(v)); + this._finetuning(0); + } + +}); +BI.MultiDateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.multi_date_time_select", BI.MultiDateTimeSelect); +/** + * Created by Urthur on 2017/7/14. + */ +BI.DateTimeTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 30 + }, + + _defaultConfig: function () { + return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-date-time-trigger", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.DateTimeTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + hgap: c.hgap, + vgap: c.vgap, + disabled: true + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: BI.createWidget(), + width: 30 + }, { + el: this.editor + }] + }) + }, + + _printTime: function (v) { + return v < 10 ? "0" + v : v; + }, + + setValue: function (v) { + var self = this; + if (BI.isNotNull(v)) { + var value = v.value, dateStr; + if(BI.isNull(value)){ + value = new Date(); + dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate()) + + " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds()); + } else { + dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day) + + " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second); + } + this.editor.setValue(dateStr); + } + } + +}); +BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger); +/** + * Created by User on 2017/3/22. + */ +Demo.MultiSelectCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-multi-select-combo" + }, + + _createMultiSelectCombo: function () { + var self = this; + var widget = BI.createWidget({ + type: 'bi.multi_select_combo', + itemsCreator: BI.bind(this._itemsCreator, this), + width: 200 + }); + + widget.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () { + BI.Msg.toast(JSON.stringify(this.getValue())); + }); + + return widget; + }, + + _getItemsByTimes: function (items, times) { + var res = []; + for (var i = (times - 1) * 3; items[i] && i < times * 3; i++) { + res.push(items[i]); + } + return res; + }, + + _hasNextByTimes: function (items, times) { + return times * 3 < items.length; + }, + + _itemsCreator: function (options, callback) { + var self = this; + var items = Demo.CONSTANTS.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.selected_values) {//过滤 + var filter = BI.makeObject(options.selected_values, 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; + } + BI.delay(function () { + callback({ + items: self._getItemsByTimes(items, options.times), + hasNext: self._hasNextByTimes(items, options.times) + }); + }, 1000); + }, + + render: function () { + return { + type: 'bi.absolute', + scrolly: false, + items: [{ + el: this._createMultiSelectCombo(), + right: "50%", + top: 10 + }] + } + } +}); +BI.shortcut("demo.multi_select_combo", Demo.MultiSelectCombo);/** + * Created by Dailer on 2017/7/13. + */ +Demo.MultiTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + var self = this; + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.multi_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + itemsCreator: function (options, callback) { + console.log(options); + + + callback({ + items: items + }); + }, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.tree.getValue())); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.multi_tree_combo", Demo.MultiTreeCombo);/** + * Created by Dailer on 2017/7/12. + */ +Demo.NumericalInterval = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + + mounted: function () { + var numerical = this.numerical; + var label = this.label; + numerical.on(BI.NumericalInterval.EVENT_CHANGE, function () { + var temp = numerical.getValue(); + var res = "大于" + (temp.closemin ? "等于 " : " ") + temp.min + " 小于" + (temp.closemax ? "等于 " : " ") + temp.max; + label.setValue(res); + }) + }, + + + + + render: function () { + var self = this; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.numerical_interval", + ref: function (_ref) { + self.numerical = _ref; + }, + width: 500 + }, { + type: "bi.label", + ref: function (_ref) { + self.label = _ref; + }, + text: "显示结果" + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.numberical_interval", Demo.NumericalInterval); + + +Demo.DirectionPathChooser = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-direction-path-chooser" + }, + + render: function () { + return { + type: "bi.center_adapt", + items: [ + { + type: "bi.direction_path_chooser", + items: [[{ + "region": "8c4460bc3605685e", + "regionText": "采购订单XXX", + "text": "ID", + "value": "1" + }, { + "region": "0fbd0dc648f41e97", + "regionText": "采购订单", + "text": "学号", + "value": "3" + }, { + "region": "c6d72d6c7e19a667", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }], [{ + "region": "ed013e18cc7c8637", + "regionText": "采购订单XXX", + "text": "ID", + "value": "1" + }, { + "region": "153d75878431f8ee", + "regionText": "A3", + "text": "学号", + "value": "2" + }, { + "region": "3861fb024c7d7825", + "regionText": "采购订单", + "text": "学号", + "value": "3" + }, { + "region": "88e3e5071bd10bc5", + "regionText": "供应商", + "text": "ID", + "value": "4" + }, { + "region": "8476c77ab5c147e0", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }], [{ + "region": "f00f67fbb9fba6fe", + "regionText": "采购订单XXX", + "text": "ID", + "value": "1" + }, { + "region": "1e8badf5d5793408", + "regionText": "A3", + "text": "学号", + "value": "2" + }, { + "region": "de1ebd3d0986a294", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }]] + } + ] + } + } +}) + +BI.shortcut("demo.direction_path_chooser",Demo.DirectionPathChooser);/** + * Created by User on 2017/3/22. + */ +Demo.PathChooser = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-path-chooser" + }, + render: function () { + var pathchooser = BI.createWidget({ + type: "bi.path_chooser", + width: 800, + height: 400, + items: // [ + // [{region: "区域X", value: "X1"}, + // {region: "区域Q", value: "Q"}, + // {region: "区域A", value: "A"}, + // {region: "区域B", value: "B"}, + // {region: "区域D", value: "D"}, + // {region: "区域E", value: "E"}, + // {region: "区域G", value: "G"}, + // {region: "区域I", value: "I"}, + // {region: "区域J", value: "J"}], + // [{region: "区域X", value: "X"}, + // {region: "区域Q", value: "Q"}, + // {region: "区域A", value: "A"}, + // {region: "区域B", value: "B"}, + // {region: "区域C", value: "C"}, + // {region: "区域D", value: "D"}, + // {region: "区域E", value: "E"}, + // {region: "区域G", value: "G"}, + // {region: "区域I", value: "I"}, + // {region: "区域J", value: "J"}], + // [{region: "区域X", value: "X"}, + // //{region: "区域Q", value: "Q"}, + // {region: "区域A", value: "A"}, // {region: "区域C", value: "C"}, // {region: "区域D", value: "D"}, // {region: "区域E", value: "E"}, @@ -6170,143 +7994,630 @@ Demo.PathChooser = BI.inherit(BI.Widget, { "text": "ID", "value": "1" }, { - "region": "0fbd0dc648f41e97", - "regionText": "采购订单", - "text": "学号", - "value": "3" + "region": "0fbd0dc648f41e97", + "regionText": "采购订单", + "text": "学号", + "value": "3" + }, { + "region": "c6d72d6c7e19a667", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }], [{ + "region": "ed013e18cc7c8637", + "regionText": "采购订单XXX", + "text": "ID", + "value": "1" + }, { + "region": "153d75878431f8ee", + "regionText": "A3", + "text": "学号", + "value": "2" + }, { + "region": "3861fb024c7d7825", + "regionText": "采购订单", + "text": "学号", + "value": "3" + }, { + "region": "88e3e5071bd10bc5", + "regionText": "供应商", + "text": "ID", + "value": "4" + }, { + "region": "8476c77ab5c147e0", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }], [{ + "region": "f00f67fbb9fba6fe", + "regionText": "采购订单XXX", + "text": "ID", + "value": "1" + }, { + "region": "1e8badf5d5793408", + "regionText": "A3", + "text": "学号", + "value": "2" + }, { + "region": "de1ebd3d0986a294", + "regionText": "供应商基本信息", + "text": "ID", + "value": "5" + }]] + }); + pathchooser.setValue(); + return { + type: "bi.absolute", + items: [{ + el: pathchooser, + left: 100, + top: 100 + }, { + el: { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast(JSON.stringify(pathchooser.getValue())); + } + }, + left: 100, + bottom: 10 + }] + } + } +}); +BI.shortcut("demo.path_chooser", Demo.PathChooser);/** + * Created by Dailer on 2017/7/11. + */ +Demo.Quarter = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.quarter_combo", + width: 300 + }] + + } + } +}) + +BI.shortcut("demo.quarter", Demo.Quarter);/** + * Created by User on 2017/3/22. + */ +Demo.RelationView = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-relation-view" + }, + render: function () { + var relationview = BI.createWidget({ + type: "bi.relation_view", + items: [ + { + primary: { + region: "B", regionText: "比", regionTitle: "bbb", regionHandler: function () { + alert("a") + }, + + + title: "b2...", + value: "b2", text: "b2字段", + handler: function () { + alert("d") + } + }, + foreign: {region: "C", value: "c1", text: "c1字段"} + }, + { + primary: {region: "A", value: "a1", text: "a1字段"}, + foreign: {region: "C", value: "c2", text: "c2字段"} + }, + { + primary: {region: "C", value: "c3", text: "c3字段"}, + foreign: {region: "D", value: "d1", text: "d1字段"} + }, + { + primary: {region: "A", value: "a1", text: "a1字段"}, + foreign: {region: "B", value: "b1", text: "b1字段"} + }, + + { + primary: {region: "X", value: "x1", text: "x1字段"}, + foreign: {region: "Y", value: "y1", text: "y1字段"} + }, + { + primary: {region: "X", value: "x2", text: "x2字段"}, + foreign: {region: "Z", value: "z1", text: "z1字段"} + }, + { + primary: {region: "X", value: "x2", text: "x2字段"}, + foreign: {region: "B", value: "b1", text: "b1字段"} + }, + { + primary: {region: "X33", value: "x233", text: "x233字段"}, + } + ] + }); + return { + type: "bi.float_center_adapt", + items: [{ + el: relationview + }] + } + } +}); +BI.shortcut("demo.relation_view", Demo.RelationView);/** + * Created by Dailer on 2017/7/13. + */ +Demo.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + var self = this; + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.multilayer_select_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + text: "默认值", + items: items, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(self.tree.getValue()[0]); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiLayerSelectTreeCombo);/** + * Created by Dailer on 2017/7/13. + */ +Demo.SelectTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + + render: function () { + var self = this; + var items = [{ + id: 1, + text: "第一项", + value: 1, + isParent: true, + title: "第一项" + }, { + id: 2, + text: "第二项", + value: 2, + isParent: true, + title: "第二项" + }, { + id: 3, + text: "第三项", + value: 3, + isParent: true, + open: true, + title: "第三项" + }, { + id: 4, + text: "第四项", + value: 4, + isParent: true, + title: "第四项" + }, { + id: 5, + text: "第五项", + value: 5, + isParent: true, + title: "第五项" + }, { + id: 6, + text: "第六项", + value: 6, + isParent: true, + open: true, + title: "第六项" + }, { + id: 7, + text: "第七项", + value: 7, + isParent: true, + open: true, + title: "第七项" + }, { + id: 11, + pId: 1, + text: "子项1", + value: 11, + title: "子项1" + }, { + id: 12, + pId: 1, + text: "子项2", + value: 12, + title: "子项2" + }, { + id: 13, + pId: 1, + text: "子项3", + value: 13, + title: "子项3" + }, { + id: 21, + pId: 2, + text: "子项1", + value: 21, + title: "子项1" + }, { + id: 22, + pId: 2, + text: "子项2", + value: 22, + title: "子项2" + }, { + id: 31, + pId: 3, + text: "子项1", + value: 31, + title: "子项1" + }, { + id: 32, + pId: 3, + text: "子项2", + value: 32, + title: "子项2" + }, { + id: 33, + pId: 3, + text: "子项3", + value: 33, + title: "子项3" + }, { + id: 41, + pId: 4, + text: "子项1", + value: 41, + title: "子项1" + }, { + id: 42, + pId: 4, + text: "子项2", + value: 42, + title: "子项2" + }, { + id: 43, + pId: 4, + text: "子项3", + value: 43, + title: "子项3" + }, { + id: 51, + pId: 5, + text: "子项1", + value: 51, + title: "子项1" + }, { + id: 52, + pId: 5, + text: "子项2", + value: 52, + title: "子项2" + }, { + id: 61, + pId: 6, + text: "子项1", + value: 61, + title: "子项1" + }, { + id: 62, + pId: 6, + text: "子项2", + value: 62, + title: "子项2" + }, { + id: 71, + pId: 7, + text: "子项1", + value: 71, + title: "子项1" + }, { + id: 72, + pId: 7, + text: "子项2", + value: 72, + title: "子项2" + }]; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.select_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + text: "默认值", + items: items, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(self.tree.getValue()[0]); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.select_tree_combo", Demo.SelectTreeCombo);/** + * Created by Dailer on 2017/7/13. + */ +Demo.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + var self = this; + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.multilayer_single_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + text: "默认值", + items: items, + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(self.tree.getValue()[0]); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.multilayer_single_tree_combo", Demo.MultiLayerSingleTreeCombo);/** + * Created by Dailer on 2017/7/13. + */ +Demo.SingleTreeCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + + render: function () { + var self = this; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.single_tree_combo", + ref: function (_ref) { + self.tree = _ref; + }, + text: "默认值", + items: [{ + id: 1, + text: "第一项", + value: 1, + isParent: true, + title: "第一项" + }, { + id: 2, + text: "第二项", + value: 1, + isParent: true, + title: "第二项" + }, { + id: 3, + text: "第三项", + value: 1, + isParent: true, + open: true, + title: "第三项" + }, { + id: 4, + text: "第四项", + value: 1, + isParent: true, + title: "第四项" + }, { + id: 5, + text: "第五项", + value: 1, + isParent: true, + title: "第五项" + }, { + id: 6, + text: "第六项", + value: 1, + isParent: true, + open: true, + title: "第六项" + }, { + id: 7, + text: "第七项", + value: 1, + isParent: true, + open: true, + title: "第七项" + }, { + id: 11, + pId: 1, + text: "子项1", + value: 11, + title: "子项1" + }, { + id: 12, + pId: 1, + text: "子项2", + value: 12, + title: "子项2" + }, { + id: 13, + pId: 1, + text: "子项3", + value: 13, + title: "子项3" + }, { + id: 21, + pId: 2, + text: "子项1", + value: 21, + title: "子项1" }, { - "region": "c6d72d6c7e19a667", - "regionText": "供应商基本信息", - "text": "ID", - "value": "5" - }], [{ - "region": "ed013e18cc7c8637", - "regionText": "采购订单XXX", - "text": "ID", - "value": "1" + id: 22, + pId: 2, + text: "子项2", + value: 22, + title: "子项2" }, { - "region": "153d75878431f8ee", - "regionText": "A3", - "text": "学号", - "value": "2" + id: 31, + pId: 3, + text: "子项1", + value: 31, + title: "子项1" }, { - "region": "3861fb024c7d7825", - "regionText": "采购订单", - "text": "学号", - "value": "3" + id: 32, + pId: 3, + text: "子项2", + value: 32, + title: "子项2" }, { - "region": "88e3e5071bd10bc5", - "regionText": "供应商", - "text": "ID", - "value": "4" + id: 33, + pId: 3, + text: "子项3", + value: 33, + title: "子项3" }, { - "region": "8476c77ab5c147e0", - "regionText": "供应商基本信息", - "text": "ID", - "value": "5" - }], [{ - "region": "f00f67fbb9fba6fe", - "regionText": "采购订单XXX", - "text": "ID", - "value": "1" + id: 41, + pId: 4, + text: "子项1", + value: 41, + title: "子项1" }, { - "region": "1e8badf5d5793408", - "regionText": "A3", - "text": "学号", - "value": "2" + id: 42, + pId: 4, + text: "子项2", + value: 42, + title: "子项2" }, { - "region": "de1ebd3d0986a294", - "regionText": "供应商基本信息", - "text": "ID", - "value": "5" - }]] - }); - pathchooser.setValue(); - return { - type: "bi.absolute", - items: [{ - el: pathchooser, - left: 100, - top: 100 + id: 43, + pId: 4, + text: "子项3", + value: 43, + title: "子项3" + }, { + id: 51, + pId: 5, + text: "子项1", + value: 51, + title: "子项1" + }, { + id: 52, + pId: 5, + text: "子项2", + value: 52, + title: "子项2" + }, { + id: 61, + pId: 6, + text: "子项1", + value: 61, + title: "子项1" + }, { + id: 62, + pId: 6, + text: "子项2", + value: 62, + title: "子项2" + }, { + id: 71, + pId: 7, + text: "子项1", + value: 71, + title: "子项1" + }, { + id: 72, + pId: 7, + text: "子项2", + value: 72, + title: "子项2" + }], + width: 300 }, { - el: { - type: "bi.button", - text: "getValue", - handler: function () { - BI.Msg.toast(JSON.stringify(pathchooser.getValue())); - } + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(self.tree.getValue()[0]); }, - left: 100, - bottom: 10 - }] + width: 300 + }], + vgap: 20 } } -}); -BI.shortcut("demo.path_chooser", Demo.PathChooser);/** - * Created by User on 2017/3/22. +}) + +BI.shortcut("demo.single_tree_combo", Demo.SingleTreeCombo);/** + * Created by Dailer on 2017/7/12. */ -Demo.RelationView = BI.inherit(BI.Widget, { +Demo.ExcelTable = BI.inherit(BI.Widget, { props: { - baseCls: "demo-relation-view" + baseCls: "demo-exceltable" }, render: function () { - var relationview = BI.createWidget({ - type: "bi.relation_view", - items: [ - { - primary: { - region: "B", regionText: "比", regionTitle: "bbb", regionHandler: function () { - alert("a") - }, - - - title: "b2...", - value: "b2", text: "b2字段", - handler: function () { - alert("d") - } - }, - foreign: {region: "C", value: "c1", text: "c1字段"} - }, - { - primary: {region: "A", value: "a1", text: "a1字段"}, - foreign: {region: "C", value: "c2", text: "c2字段"} - }, - { - primary: {region: "C", value: "c3", text: "c3字段"}, - foreign: {region: "D", value: "d1", text: "d1字段"} - }, - { - primary: {region: "A", value: "a1", text: "a1字段"}, - foreign: {region: "B", value: "b1", text: "b1字段"} - }, - - { - primary: {region: "X", value: "x1", text: "x1字段"}, - foreign: {region: "Y", value: "y1", text: "y1字段"} - }, - { - primary: {region: "X", value: "x2", text: "x2字段"}, - foreign: {region: "Z", value: "z1", text: "z1字段"} - }, - { - primary: {region: "X", value: "x2", text: "x2字段"}, - foreign: {region: "B", value: "b1", text: "b1字段"} - }, - { - primary: {region: "X33", value: "x233", text: "x233字段"}, - } - ] - }); return { - type: "bi.float_center_adapt", + type: "bi.horizontal_auto", items: [{ - el: relationview - }] + type: "bi.excel_table", + columnSize: [200,200,200,200,200], + items: [ + [{ + type: "bi.label", + cls: "layout-bg1", + text: "第一行第一列" + }, { + type: "bi.label", + cls: "layout-bg2", + text: "第一行第二列" + }], + [{ + type: "bi.label", + cls: "layout-bg3", + text: "第二行第一列" + }, { + type: "bi.label", + cls: "layout-bg4", + text: "第二行第二列" + }] + ] + }], + width:500 } } -}); -BI.shortcut("demo.relation_view", Demo.RelationView);Demo.Func = BI.inherit(BI.Widget, { +}) + +BI.shortcut("demo.excel_table", Demo.ExcelTable);Demo.Func = BI.inherit(BI.Widget, { props: { baseCls: "demo-func" }, @@ -7067,71 +9378,142 @@ BI.shortcut("demo.responsive_table", Demo.Func);Demo.Func = BI.inherit(BI.Widget } }); BI.shortcut("demo.sequence_table", Demo.Func);/** - * Created by User on 2017/3/22. + * Created by Dailer on 2017/7/13. */ -Demo.MultiSelectCombo = BI.inherit(BI.Widget, { - props: {}, +Demo.TimeInterval = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, - render: function (vessel) { - var TREEWITHCHILDREN = [{ - id: -1, value: "根目录", text: "根目录", children: [ - { - id: 1, value: "第一级目录1", text: "第一级目录1", children: [ - {id: 11, value: "第二级文件1", text: "第二级文件1"}, - { - id: 12, value: "第二级目录2", text: "第二级目录2", children: [ - { - id: 121, value: "第三级目录1", text: "第三级目录1", children: [ - { - id: 1211, value: "第四级目录1", text: "第四级目录1", children: [ - {id: 12111, value: "第五级文件1", text: "第五级文件1"} - ] - } - ] - }, - {id: 122, value: "第三级文件1", text: "第三级文件1"} - ] - } - ] + render: function () { + var self = this; + var items = BI.deepClone(Demo.CONSTANTS.TREE); + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.time_interval", + ref: function (_ref) { + self.interval = _ref; }, - { - id: 2, value: "第一级目录2", text: "第一级目录2", children: [ - { - id: 21, value: "第二级目录3", text: "第二级目录3", children: [ - { - id: 211, value: "第三级目录2", text: "第三级目录2", children: [ - {id: 2111, value: "第四级文件1", text: "第四级文件1"} - ] - }, - {id: 212, value: "第三级文件2", text: "第三级文件2"} - ] - }, - {id: 22, value: "第二级文件2", text: "第二级文件2"} - ] - } - ] - }]; - var items = BI.deepClone(TREEWITHCHILDREN); - var combo = BI.createWidget({ - type: "bi.multilayer_select_tree_combo", - }); + width: 300 + }, { + type: "bi.button", + text: "getVlaue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.interval.getValue())); + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.time_interval", Demo.TimeInterval);/** + * Created by Dailer on 2017/7/13. + */ +Demo.SwitchTree = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { - combo.populate(items); + var items = BI.deepClone(Demo.CONSTANTS.TREE); return { - type: "bi.vertical", - items: [combo, { + type: "bi.horizontal_auto", + items: [{ + type: "bi.switch_tree", + items: items + },{ + type:"bi.button", + text:"getValue" + }] + } + } +}) + +BI.shortcut("demo.switch_tree", Demo.SwitchTree);/** + * Created by Dailer on 2017/7/11. + */ +Demo.Year = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-exceltable" + }, + render: function () { + return { + type: "bi.horizontal_adapt", + items: [{ + type: "bi.year_combo", + width: 300 + }] + } + } +}) + +BI.shortcut("demo.year", Demo.Year);/** + * Created by Dailer on 2017/7/13. + */ +Demo.YearMonthCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + + var self = this; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.year_month_combo", + ref: function (_ref) { + self.widget = _ref; + }, + width: 300 + }, { type: "bi.button", - width: 100, text: "getValue", handler: function () { - BI.Msg.alert("", JSON.stringify(combo.getValue())); - } + BI.Msg.toast(JSON.stringify(self.widget.getValue())) + }, + width: 300 }], - vgap: 100 + vgap: 20 } } -}); -BI.shortcut("demo.multilayer_select_tree_combo", Demo.MultiSelectCombo);Demo.CONFIG = Demo.CORE_CONFIG.concat(Demo.BASE_CONFIG).concat(Demo.CASE_CONFIG).concat(Demo.WIDGET_CONFIG).concat(Demo.COMPONENT_CONFIG).concat(Demo.CHART_CONFIG); +}) + +BI.shortcut("demo.year_month_combo", Demo.YearMonthCombo);/** + * Created by Dailer on 2017/7/13. + */ +Demo.YearQuarterCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + var self=this; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.year_quarter_combo", + width: 300, + ref:function(_ref){ + self.widget=_ref; + }, + yearBehaviors: {}, + quarterBehaviors: {}, + }, { + type: "bi.button", + text: "getValue", + handler:function(){ + BI.Msg.toast(JSON.stringify(self.widget.getValue())) + }, + width: 300 + }], + vgap: 20 + } + } +}) + +BI.shortcut("demo.year_quarter_combo", Demo.YearQuarterCombo);Demo.CONFIG = Demo.CORE_CONFIG.concat(Demo.BASE_CONFIG).concat(Demo.CASE_CONFIG).concat(Demo.WIDGET_CONFIG).concat(Demo.COMPONENT_CONFIG).concat(Demo.CHART_CONFIG); Demo.CONSTANTS = { ITEMS: BI.map("柳州市城贸金属材料有限责任公司 柳州市建福房屋租赁有限公司 柳州市迅昌数码办公设备有限责任公司 柳州市河海贸易有限责任公司 柳州市花篮制衣厂 柳州市兴溪物资有限公司 柳州市针织总厂 柳州市衡管物资有限公司 柳州市琪成机电设备有限公司 柳州市松林工程机械修理厂 柳州市积玉贸易有限公司 柳州市福运来贸易有限责任公司 柳州市钢义物资有限公司 柳州市洋力化工有限公司 柳州市悦盛贸易有限公司 柳州市雁城钢管物资有限公司 柳州市恒瑞钢材经营部 柳州市科拓电子有限公司 柳州市九方电子有限公司 柳州市桂龙汽车配件厂 柳州市制鞋工厂 柳州市炜力科贸有限公司 柳州市希翼贸易有限公司 柳州市兆金物资有限公司 柳州市和润电子科技有限责任公司 柳州市汇凯贸易有限公司 柳州市好机汇商贸有限公司 柳州市泛源商贸经营部 柳州市利汇达物资有限公司 广西全民药业有限责任公司 柳州超凡物资贸易有限责任公司 柳州市贵宏物资有限责任公司 柳州昊恒贸易有限责任公司 柳州市浦联物资有限公司 柳州市广通园林绿化工程有限责任公司 柳州市松发物资贸易有限责任公司 柳州市奥士达办公设备有限责任公司 柳州市海泰物资有限公司 柳州市金三环针织厂 柳州市钢贸物资有限公司 柳州市明阳纺织有限公司 柳州市世科科技发展有限公司 柳州市禄羊贸易有限公司 柳州市金兆阳商贸有限公司 柳州市汇昌物资经营部 柳州市林泰金属物资供应站 柳州市自来水管道材料设备公司 柳州市丹柳铝板有限公司 柳州市桂冶物资有限公司 柳州市宸业物资经营部 柳州市耀成贸易有限公司 柳州奥易自动化科技有限公司 柳州市萃丰科技有限责任公司 柳州市华储贸易有限责任公司 柳州市黄颜钢材有限责任公司 柳州市银盛物资有限责任公司 柳州市新仪化玻供应站 柳州市晶凯化工有限公司 广西柳州市柳江包装纸厂 柳州市志新物资有限责任公司 柳州市兆钢物资有限公司 柳州市友方科技发展有限责任公司 柳州市缝纫机台板家具总厂 柳州市晖海数码办公设备有限责任公司 柳州市富兰特服饰有限责任公司 柳州市柳北区富兴物资经营部 柳州市柳锌福利厂 柳州市海泉印刷有限责任公司 柳州市乾亨贸易有限公司 柳州市悦宁物资贸易有限公司 柳州市昊天贸易有限公司 广西惠字钢铁有限公司 柳州市名青物资有限公司 柳州市林郝物资有限公司 柳州市民政服装厂 柳州市多维劳保用品厂 柳州市轻工物资供应公司 柳州市程源物资有限责任公司 柳州市寿丰物资贸易有限责任公司 柳州市凯凡物资有限公司 柳州市利晖物资经营部 柳州市恒茂金属物资供应站 柳州市中储物资经营部 柳州市第二医疗器械厂 柳州市来鑫物资经营部 柳州市钢鑫物资贸易有限责任公司 柳州市双合袜业有限责任公司 柳州市茂松经贸有限责任公司 柳州市行行物资贸易有限公司 柳州市方一物资有限公司 柳州成异钢管销售有限公司 柳州广惠佳电脑有限公司 桂林市圣泽鑫物资有限公司柳州分公司 柳州市砼基建材贸易有限公司 柳州市海燕针织厂 上海浦光仪表厂柳州销售处 柳州市能电工贸有限责任公司 柳州市广贸物资有限公司 柳州市柳北区大昌电工灯饰经营部 柳州市金龙印务有限公司 柳州市奇缘婚典服务有限公司 柳州市盛博物资经营部 柳州市项元钢铁贸易有限公司 柳州市虞美人化妆品经营部 柳州市俊彦鞋厂 柳州市聚源特钢有限公司 柳州市迅龙科贸有限责任公司 柳州市恒飞电子有限责任公司 柳州市蓝正现代办公设备有限责任公司 柳州地区农业生产资料公司 柳州华菱钢管销售有限公司 柳州融通物资有限公司 柳州市可仁广告策划有限责任公司 柳州市鸟鑫物资有限责任公司 柳州市五丰钢材供应站 柳州市金江不锈钢有限公司 柳州市美日物资设备有限责任公司 柳州市鑫东物资贸易有限责任公司 柳州地区日用杂品公司 柳州市华纳物资贸易有限公司 柳州乾利金虹物资贸易有限责任公司 柳州市新迈计算机有限公司 柳州市富丽实业发展公司 柳州市石钢金属材料有限公司 柳州市力志传真机销售有限公司 广西宝森投资有限公司 柳州市嵘基商贸有限公司 柳州市景民商贸有限责任公司 柳州市银桥化玻有限责任公司 柳州市宏文糖烟店 柳州市科苑电脑网络有限公司 柳州市两面针旅游用品厂 柳州市立早室内装璜有限责任公司 柳州地化建材有限公司 柳州市涛达贸易有限公司 柳州市兰丰档案服务中心 柳州市惠贸物资有限责任公司 柳州市立文物资有限责任公司 柳州市致和商贸经营部 柳州市金色阳光信息咨询有限公司 柳州市赛利钢材经销部 柳州市日用化工厂 柳州市昆廷物资有限责任公司 柳州市邦盛贸易有限公司 柳州市济华贸易有限公司 柳州昕威橡塑化工经营部 柳州市联业贸易有限公司 柳州市兰钢贸易有限公司 柳州市子欣科技有限公司 柳州市狄龙机电设备有限公司 柳州市方真物资贸易有限公司 柳州市银鸥废旧回收中心 柳州市冠宝贸易有限公司 柳州市鑫盛德商务咨询有限责任公司 柳州市泰汇银通经贸有限公司 广西瀚维智测科技有限公司 柳州市钓鱼郎制衣有限责任公司 柳州溪水物资有限公司 柳州市融峰物资有限责任公司 广西新地科技有限责任公司 柳州市纺织装饰公司 柳州市粤翔冶金炉料有限公司 柳州市远腾贸易有限公司 柳州市东鸿城市改造有限公司 广西丛欣实业有限公司 柳州市服装厂 柳州市立安联合刀片有限公司 广西国扬投资有限责任公司 柳州市铭泰办公设备公司 柳州市桂钢物资供应站 柳州市昱升物资有限责任公司 柳州市鹰飞灿科贸有限公司 柳州市先导科贸有限公司 柳州市金秋建材物资经营部 柳州市童装厂 柳州市民泽物资有限公司 柳州市恒先物资贸易有限公司 柳州市银夏冷气工程有限责任公司 柳州粮食批发有限责任公司 柳州市金银华窗纱制造有限责任公司 柳州市三方贸易有限公司 柳州市丰涛商贸有限责任公司 柳州华智企业管理咨询有限责任公司 柳州市诚正建筑工程施工图审查有限公司 柳州市今科电讯设备营销中心 柳州市闽德电子有限公司 柳州市鑫虹针织厂 柳州市畅通通讯器材有限责任公司 柳州市正钢物资经营部 柳州市新柳饲料有限责任公司 柳州市黄村油库 柳州市天泰电力装饰工程有限公司 柳州市兆吉物资有限责任公司 柳州市八龙纸制品有限责任公司 柳州市巨佳电脑网络科技有限公司 ".match(/[^\s]+/g), function (i, v) { @@ -7141,6 +9523,21 @@ Demo.CONSTANTS = { title: v } }), - TREEITEMS: [{"pId":"0","id":"0_0","text":"( 共25个 )","value":"","open":true},{"pId":"0_0","id":"0_0_0","text":"安徽省( 共1个 )","value":"安徽省","open":true},{"pId":"0_0_0","id":"0_0_0_0","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_0","id":"0_0_1","text":"北京市( 共6个 )","value":"北京市","open":true},{"pId":"0_0_1","id":"0_0_1_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_0_1","id":"0_0_1_1","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_0_1","id":"0_0_1_2","text":"东城区","value":"东城区","open":true},{"pId":"0_0_1","id":"0_0_1_3","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_0_1","id":"0_0_1_4","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_0_1","id":"0_0_1_5","text":"石景山区","value":"石景山区","open":true},{"pId":"0_0","id":"0_0_2","text":"福建省( 共2个 )","value":"福建省","open":true},{"pId":"0_0_2","id":"0_0_2_0","text":"莆田市","value":"莆田市","open":true},{"pId":"0_0_2","id":"0_0_2_1","text":"泉州市","value":"泉州市","open":true},{"pId":"0_0","id":"0_0_3","text":"甘肃省( 共1个 )","value":"甘肃省","open":true},{"pId":"0_0_3","id":"0_0_3_0","text":"兰州市","value":"兰州市","open":true},{"pId":"0_0","id":"0_0_4","text":"广东省( 共5个 )","value":"广东省","open":true},{"pId":"0_0_4","id":"0_0_4_0","text":"东莞市","value":"东莞市","open":true},{"pId":"0_0_4","id":"0_0_4_1","text":"广州市","value":"广州市","open":true},{"pId":"0_0_4","id":"0_0_4_2","text":"惠州市","value":"惠州市","open":true},{"pId":"0_0_4","id":"0_0_4_3","text":"深圳市","value":"深圳市","open":true},{"pId":"0_0_4","id":"0_0_4_4","text":"珠海市","value":"珠海市","open":true},{"pId":"0_0","id":"0_0_5","text":"广西壮族自治区( 共1个 )","value":"广西壮族自治区","open":true},{"pId":"0_0_5","id":"0_0_5_0","text":"南宁市","value":"南宁市","open":true},{"pId":"0_0","id":"0_0_6","text":"河北省( 共2个 )","value":"河北省","open":true},{"pId":"0_0_6","id":"0_0_6_0","text":"保定市","value":"保定市","open":true},{"pId":"0_0_6","id":"0_0_6_1","text":"邢台市","value":"邢台市","open":true},{"pId":"0_0","id":"0_0_7","text":"河南省( 共1个 )","value":"河南省","open":true},{"pId":"0_0_7","id":"0_0_7_0","text":"郑州市","value":"郑州市","open":true},{"pId":"0_0","id":"0_0_8","text":"黑龙江省( 共7个 )","value":"黑龙江省","open":true},{"pId":"0_0_8","id":"0_0_8_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_0_8","id":"0_0_8_1","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_0_8","id":"0_0_8_2","text":"鸡西市","value":"鸡西市","open":true},{"pId":"0_0_8","id":"0_0_8_3","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_0_8","id":"0_0_8_4","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_0_8","id":"0_0_8_5","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_0_8","id":"0_0_8_6","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_0","id":"0_0_9","text":"湖北省( 共1个 )","value":"湖北省","open":true},{"pId":"0_0_9","id":"0_0_9_0","text":"武汉市","value":"武汉市","open":true},{"pId":"0_0","id":"0_0_10","text":"湖南省( 共3个 )","value":"湖南省","open":true},{"pId":"0_0_10","id":"0_0_10_0","text":"常德市","value":"常德市","open":true},{"pId":"0_0_10","id":"0_0_10_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_0_10","id":"0_0_10_2","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_0","id":"0_0_11","text":"吉林省( 共4个 )","value":"吉林省","open":true},{"pId":"0_0_11","id":"0_0_11_0","text":"白山市","value":"白山市","open":true},{"pId":"0_0_11","id":"0_0_11_1","text":"长春市","value":"长春市","open":true},{"pId":"0_0_11","id":"0_0_11_2","text":"松原市","value":"松原市","open":true},{"pId":"0_0_11","id":"0_0_11_3","text":"通化市","value":"通化市","open":true},{"pId":"0_0","id":"0_0_12","text":"江苏省( 共8个 )","value":"江苏省","open":true},{"pId":"0_0_12","id":"0_0_12_0","text":"常州市","value":"常州市","open":true},{"pId":"0_0_12","id":"0_0_12_1","text":"南京市","value":"南京市","open":true},{"pId":"0_0_12","id":"0_0_12_2","text":"南通市","value":"南通市","open":true},{"pId":"0_0_12","id":"0_0_12_3","text":"苏州市","value":"苏州市","open":true},{"pId":"0_0_12","id":"0_0_12_4","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_0_12","id":"0_0_12_5","text":"泰州市","value":"泰州市","open":true},{"pId":"0_0_12","id":"0_0_12_6","text":"无锡市","value":"无锡市","open":true},{"pId":"0_0_12","id":"0_0_12_7","text":"盐城市","value":"盐城市","open":true},{"pId":"0_0","id":"0_0_13","text":"辽宁省( 共11个 )","value":"辽宁省","open":true},{"pId":"0_0_13","id":"0_0_13_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_0_13","id":"0_0_13_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_0_13","id":"0_0_13_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_0_13","id":"0_0_13_3","text":"大连市","value":"大连市","open":true},{"pId":"0_0_13","id":"0_0_13_4","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_0_13","id":"0_0_13_5","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_0_13","id":"0_0_13_6","text":"锦州市","value":"锦州市","open":true},{"pId":"0_0_13","id":"0_0_13_7","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_0_13","id":"0_0_13_8","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_0_13","id":"0_0_13_9","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_0_13","id":"0_0_13_10","text":"营口市","value":"营口市","open":true},{"pId":"0_0","id":"0_0_14","text":"内蒙古( 共1个 )","value":"内蒙古","open":true},{"pId":"0_0_14","id":"0_0_14_0","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_0","id":"0_0_15","text":"宁夏回族自治区( 共1个 )","value":"宁夏回族自治区","open":true},{"pId":"0_0_15","id":"0_0_15_0","text":"银川市","value":"银川市","open":true},{"pId":"0_0","id":"0_0_16","text":"山东省( 共7个 )","value":"山东省","open":true},{"pId":"0_0_16","id":"0_0_16_0","text":"济南市","value":"济南市","open":true},{"pId":"0_0_16","id":"0_0_16_1","text":"济宁市","value":"济宁市","open":true},{"pId":"0_0_16","id":"0_0_16_2","text":"聊城市","value":"聊城市","open":true},{"pId":"0_0_16","id":"0_0_16_3","text":"临沂市","value":"临沂市","open":true},{"pId":"0_0_16","id":"0_0_16_4","text":"青岛市","value":"青岛市","open":true},{"pId":"0_0_16","id":"0_0_16_5","text":"烟台市","value":"烟台市","open":true},{"pId":"0_0_16","id":"0_0_16_6","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_0","id":"0_0_17","text":"山西省( 共1个 )","value":"山西省","open":true},{"pId":"0_0_17","id":"0_0_17_0","text":"太原市","value":"太原市","open":true},{"pId":"0_0","id":"0_0_18","text":"陕西省( 共1个 )","value":"陕西省","open":true},{"pId":"0_0_18","id":"0_0_18_0","text":"西安市","value":"西安市","open":true},{"pId":"0_0","id":"0_0_19","text":"上海市( 共1个 )","value":"上海市","open":true},{"pId":"0_0_19","id":"0_0_19_0","text":"上海市区","value":"上海市区","open":true},{"pId":"0_0","id":"0_0_20","text":"四川省( 共1个 )","value":"四川省","open":true},{"pId":"0_0_20","id":"0_0_20_0","text":"成都市","value":"成都市","open":true},{"pId":"0_0","id":"0_0_21","text":"新疆维吾尔族自治区( 共2个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_0_21","id":"0_0_21_0","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_0_21","id":"0_0_21_1","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_0","id":"0_0_22","text":"云南省( 共1个 )","value":"云南省","open":true},{"pId":"0_0_22","id":"0_0_22_0","text":"昆明市","value":"昆明市","open":true},{"pId":"0_0","id":"0_0_23","text":"浙江省( 共5个 )","value":"浙江省","open":true},{"pId":"0_0_23","id":"0_0_23_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_0_23","id":"0_0_23_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_0_23","id":"0_0_23_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_0_23","id":"0_0_23_3","text":"宁波市","value":"宁波市","open":true},{"pId":"0_0_23","id":"0_0_23_4","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_0","id":"0_0_24","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_0_24","id":"0_0_24_0","text":"重庆市区","value":"重庆市区","open":true},{"pId":"0","id":"0_1","text":"中国( 共34个 )","value":"中国","open":true},{"pId":"0_1","id":"0_1_0","text":"安徽省( 共19个 )","value":"安徽省","open":true},{"pId":"0_1_0","id":"0_1_0_0","text":"安庆市","value":"安庆市","open":true},{"pId":"0_1_0","id":"0_1_0_1","text":"蚌埠市","value":"蚌埠市","open":true},{"pId":"0_1_0","id":"0_1_0_2","text":"亳州市","value":"亳州市","open":true},{"pId":"0_1_0","id":"0_1_0_3","text":"巢湖市","value":"巢湖市","open":true},{"pId":"0_1_0","id":"0_1_0_4","text":"池州市","value":"池州市","open":true},{"pId":"0_1_0","id":"0_1_0_5","text":"滁州市","value":"滁州市","open":true},{"pId":"0_1_0","id":"0_1_0_6","text":"阜阳市","value":"阜阳市","open":true},{"pId":"0_1_0","id":"0_1_0_7","text":"毫州市","value":"毫州市","open":true},{"pId":"0_1_0","id":"0_1_0_8","text":"合肥市","value":"合肥市","open":true},{"pId":"0_1_0","id":"0_1_0_9","text":"淮北市","value":"淮北市","open":true},{"pId":"0_1_0","id":"0_1_0_10","text":"淮南市","value":"淮南市","open":true},{"pId":"0_1_0","id":"0_1_0_11","text":"黄山市","value":"黄山市","open":true},{"pId":"0_1_0","id":"0_1_0_12","text":"六安市","value":"六安市","open":true},{"pId":"0_1_0","id":"0_1_0_13","text":"马鞍山市","value":"马鞍山市","open":true},{"pId":"0_1_0","id":"0_1_0_14","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_0","id":"0_1_0_15","text":"宿州市","value":"宿州市","open":true},{"pId":"0_1_0","id":"0_1_0_16","text":"铜陵市","value":"铜陵市","open":true},{"pId":"0_1_0","id":"0_1_0_17","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_1_0","id":"0_1_0_18","text":"宣城市","value":"宣城市","open":true},{"pId":"0_1","id":"0_1_1","text":"澳门特别行政区( 共1个 )","value":"澳门特别行政区","open":true},{"pId":"0_1_1","id":"0_1_1_0","text":"澳门","value":"澳门","open":true},{"pId":"0_1","id":"0_1_2","text":"北京市( 共17个 )","value":"北京市","open":true},{"pId":"0_1_2","id":"0_1_2_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_1_2","id":"0_1_2_1","text":"昌平区","value":"昌平区","open":true},{"pId":"0_1_2","id":"0_1_2_2","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_1_2","id":"0_1_2_3","text":"大兴区","value":"大兴区","open":true},{"pId":"0_1_2","id":"0_1_2_4","text":"东城区","value":"东城区","open":true},{"pId":"0_1_2","id":"0_1_2_5","text":"房山区","value":"房山区","open":true},{"pId":"0_1_2","id":"0_1_2_6","text":"丰台区","value":"丰台区","open":true},{"pId":"0_1_2","id":"0_1_2_7","text":"海淀区","value":"海淀区","open":true},{"pId":"0_1_2","id":"0_1_2_8","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_1_2","id":"0_1_2_9","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_1_2","id":"0_1_2_10","text":"门头沟区","value":"门头沟区","open":true},{"pId":"0_1_2","id":"0_1_2_11","text":"平谷区","value":"平谷区","open":true},{"pId":"0_1_2","id":"0_1_2_12","text":"石景山区","value":"石景山区","open":true},{"pId":"0_1_2","id":"0_1_2_13","text":"顺义区","value":"顺义区","open":true},{"pId":"0_1_2","id":"0_1_2_14","text":"通州区","value":"通州区","open":true},{"pId":"0_1_2","id":"0_1_2_15","text":"西城区","value":"西城区","open":true},{"pId":"0_1_2","id":"0_1_2_16","text":"西城区 ","value":"西城区 ","open":true},{"pId":"0_1","id":"0_1_3","text":"福建省( 共9个 )","value":"福建省","open":true},{"pId":"0_1_3","id":"0_1_3_0","text":"福州市","value":"福州市","open":true},{"pId":"0_1_3","id":"0_1_3_1","text":"龙岩市","value":"龙岩市","open":true},{"pId":"0_1_3","id":"0_1_3_2","text":"南平市","value":"南平市","open":true},{"pId":"0_1_3","id":"0_1_3_3","text":"宁德市","value":"宁德市","open":true},{"pId":"0_1_3","id":"0_1_3_4","text":"莆田市","value":"莆田市","open":true},{"pId":"0_1_3","id":"0_1_3_5","text":"泉州市","value":"泉州市","open":true},{"pId":"0_1_3","id":"0_1_3_6","text":"三明市","value":"三明市","open":true},{"pId":"0_1_3","id":"0_1_3_7","text":"厦门市","value":"厦门市","open":true},{"pId":"0_1_3","id":"0_1_3_8","text":"漳州市","value":"漳州市","open":true},{"pId":"0_1","id":"0_1_4","text":"甘肃省( 共12个 )","value":"甘肃省","open":true},{"pId":"0_1_4","id":"0_1_4_0","text":"白银市","value":"白银市","open":true},{"pId":"0_1_4","id":"0_1_4_1","text":"嘉峪关市","value":"嘉峪关市","open":true},{"pId":"0_1_4","id":"0_1_4_2","text":"金昌市","value":"金昌市","open":true},{"pId":"0_1_4","id":"0_1_4_3","text":"酒泉市","value":"酒泉市","open":true},{"pId":"0_1_4","id":"0_1_4_4","text":"兰州市","value":"兰州市","open":true},{"pId":"0_1_4","id":"0_1_4_5","text":"陇南市","value":"陇南市","open":true},{"pId":"0_1_4","id":"0_1_4_6","text":"平凉市","value":"平凉市","open":true},{"pId":"0_1_4","id":"0_1_4_7","text":"庆阳市","value":"庆阳市","open":true},{"pId":"0_1_4","id":"0_1_4_8","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_4","id":"0_1_4_9","text":"天水市","value":"天水市","open":true},{"pId":"0_1_4","id":"0_1_4_10","text":"武威市","value":"武威市","open":true},{"pId":"0_1_4","id":"0_1_4_11","text":"张掖市","value":"张掖市","open":true},{"pId":"0_1","id":"0_1_5","text":"广东省( 共21个 )","value":"广东省","open":true},{"pId":"0_1_5","id":"0_1_5_0","text":"潮州市","value":"潮州市","open":true},{"pId":"0_1_5","id":"0_1_5_1","text":"东莞市","value":"东莞市","open":true},{"pId":"0_1_5","id":"0_1_5_2","text":"佛山市","value":"佛山市","open":true},{"pId":"0_1_5","id":"0_1_5_3","text":"广州市","value":"广州市","open":true},{"pId":"0_1_5","id":"0_1_5_4","text":"河源市","value":"河源市","open":true},{"pId":"0_1_5","id":"0_1_5_5","text":"惠州市","value":"惠州市","open":true},{"pId":"0_1_5","id":"0_1_5_6","text":"江门市","value":"江门市","open":true},{"pId":"0_1_5","id":"0_1_5_7","text":"揭阳市","value":"揭阳市","open":true},{"pId":"0_1_5","id":"0_1_5_8","text":"茂名市","value":"茂名市","open":true},{"pId":"0_1_5","id":"0_1_5_9","text":"梅州市","value":"梅州市","open":true},{"pId":"0_1_5","id":"0_1_5_10","text":"清远市","value":"清远市","open":true},{"pId":"0_1_5","id":"0_1_5_11","text":"汕头市","value":"汕头市","open":true},{"pId":"0_1_5","id":"0_1_5_12","text":"汕尾市","value":"汕尾市","open":true},{"pId":"0_1_5","id":"0_1_5_13","text":"韶关市","value":"韶关市","open":true},{"pId":"0_1_5","id":"0_1_5_14","text":"深圳市","value":"深圳市","open":true},{"pId":"0_1_5","id":"0_1_5_15","text":"阳江市","value":"阳江市","open":true},{"pId":"0_1_5","id":"0_1_5_16","text":"云浮市","value":"云浮市","open":true},{"pId":"0_1_5","id":"0_1_5_17","text":"湛江市","value":"湛江市","open":true},{"pId":"0_1_5","id":"0_1_5_18","text":"肇庆市","value":"肇庆市","open":true},{"pId":"0_1_5","id":"0_1_5_19","text":"中山市","value":"中山市","open":true},{"pId":"0_1_5","id":"0_1_5_20","text":"珠海市","value":"珠海市","open":true},{"pId":"0_1","id":"0_1_6","text":"广西壮族自治区( 共14个 )","value":"广西壮族自治区","open":true},{"pId":"0_1_6","id":"0_1_6_0","text":"百色市","value":"百色市","open":true},{"pId":"0_1_6","id":"0_1_6_1","text":"北海市","value":"北海市","open":true},{"pId":"0_1_6","id":"0_1_6_2","text":"崇左市","value":"崇左市","open":true},{"pId":"0_1_6","id":"0_1_6_3","text":"防城港市","value":"防城港市","open":true},{"pId":"0_1_6","id":"0_1_6_4","text":"桂林市","value":"桂林市","open":true},{"pId":"0_1_6","id":"0_1_6_5","text":"贵港市","value":"贵港市","open":true},{"pId":"0_1_6","id":"0_1_6_6","text":"河池市","value":"河池市","open":true},{"pId":"0_1_6","id":"0_1_6_7","text":"贺州市","value":"贺州市","open":true},{"pId":"0_1_6","id":"0_1_6_8","text":"来宾市","value":"来宾市","open":true},{"pId":"0_1_6","id":"0_1_6_9","text":"柳州市","value":"柳州市","open":true},{"pId":"0_1_6","id":"0_1_6_10","text":"南宁市","value":"南宁市","open":true},{"pId":"0_1_6","id":"0_1_6_11","text":"钦州市","value":"钦州市","open":true},{"pId":"0_1_6","id":"0_1_6_12","text":"梧州市","value":"梧州市","open":true},{"pId":"0_1_6","id":"0_1_6_13","text":"玉林市","value":"玉林市","open":true},{"pId":"0_1","id":"0_1_7","text":"贵州省( 共9个 )","value":"贵州省","open":true},{"pId":"0_1_7","id":"0_1_7_0","text":"安顺市","value":"安顺市","open":true},{"pId":"0_1_7","id":"0_1_7_1","text":"毕节地区","value":"毕节地区","open":true},{"pId":"0_1_7","id":"0_1_7_2","text":"贵阳市","value":"贵阳市","open":true},{"pId":"0_1_7","id":"0_1_7_3","text":"六盘水市","value":"六盘水市","open":true},{"pId":"0_1_7","id":"0_1_7_4","text":"黔东南州","value":"黔东南州","open":true},{"pId":"0_1_7","id":"0_1_7_5","text":"黔南州","value":"黔南州","open":true},{"pId":"0_1_7","id":"0_1_7_6","text":"黔西南市","value":"黔西南市","open":true},{"pId":"0_1_7","id":"0_1_7_7","text":"铜仁地区","value":"铜仁地区","open":true},{"pId":"0_1_7","id":"0_1_7_8","text":"遵义市","value":"遵义市","open":true},{"pId":"0_1","id":"0_1_8","text":"海南省( 共2个 )","value":"海南省","open":true},{"pId":"0_1_8","id":"0_1_8_0","text":"海口市","value":"海口市","open":true},{"pId":"0_1_8","id":"0_1_8_1","text":"三亚市","value":"三亚市","open":true},{"pId":"0_1","id":"0_1_9","text":"河北省( 共12个 )","value":"河北省","open":true},{"pId":"0_1_9","id":"0_1_9_0","text":"保定市","value":"保定市","open":true},{"pId":"0_1_9","id":"0_1_9_1","text":"沧州市","value":"沧州市","open":true},{"pId":"0_1_9","id":"0_1_9_2","text":"承德市","value":"承德市","open":true},{"pId":"0_1_9","id":"0_1_9_3","text":"邯郸市","value":"邯郸市","open":true},{"pId":"0_1_9","id":"0_1_9_4","text":"衡水市","value":"衡水市","open":true},{"pId":"0_1_9","id":"0_1_9_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_9","id":"0_1_9_6","text":"秦皇岛市","value":"秦皇岛市","open":true},{"pId":"0_1_9","id":"0_1_9_7","text":"石家庄市","value":"石家庄市","open":true},{"pId":"0_1_9","id":"0_1_9_8","text":"唐山市","value":"唐山市","open":true},{"pId":"0_1_9","id":"0_1_9_9","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_9","id":"0_1_9_10","text":"邢台市","value":"邢台市","open":true},{"pId":"0_1_9","id":"0_1_9_11","text":"张家口市","value":"张家口市","open":true},{"pId":"0_1","id":"0_1_10","text":"河南省( 共19个 )","value":"河南省","open":true},{"pId":"0_1_10","id":"0_1_10_0","text":"安阳市","value":"安阳市","open":true},{"pId":"0_1_10","id":"0_1_10_1","text":"鹤壁市","value":"鹤壁市","open":true},{"pId":"0_1_10","id":"0_1_10_2","text":"济源市","value":"济源市","open":true},{"pId":"0_1_10","id":"0_1_10_3","text":"焦作市","value":"焦作市","open":true},{"pId":"0_1_10","id":"0_1_10_4","text":"开封市","value":"开封市","open":true},{"pId":"0_1_10","id":"0_1_10_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_10","id":"0_1_10_6","text":"洛阳市","value":"洛阳市","open":true},{"pId":"0_1_10","id":"0_1_10_7","text":"漯河市","value":"漯河市","open":true},{"pId":"0_1_10","id":"0_1_10_8","text":"南阳市","value":"南阳市","open":true},{"pId":"0_1_10","id":"0_1_10_9","text":"平顶山市","value":"平顶山市","open":true},{"pId":"0_1_10","id":"0_1_10_10","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_10","id":"0_1_10_11","text":"三门峡市","value":"三门峡市","open":true},{"pId":"0_1_10","id":"0_1_10_12","text":"商丘市","value":"商丘市","open":true},{"pId":"0_1_10","id":"0_1_10_13","text":"新乡市","value":"新乡市","open":true},{"pId":"0_1_10","id":"0_1_10_14","text":"信阳市","value":"信阳市","open":true},{"pId":"0_1_10","id":"0_1_10_15","text":"许昌市","value":"许昌市","open":true},{"pId":"0_1_10","id":"0_1_10_16","text":"郑州市","value":"郑州市","open":true},{"pId":"0_1_10","id":"0_1_10_17","text":"周口市","value":"周口市","open":true},{"pId":"0_1_10","id":"0_1_10_18","text":"驻马店市","value":"驻马店市","open":true},{"pId":"0_1","id":"0_1_11","text":"黑龙江省( 共13个 )","value":"黑龙江省","open":true},{"pId":"0_1_11","id":"0_1_11_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_11","id":"0_1_11_1","text":"大兴安岭地区","value":"大兴安岭地区","open":true},{"pId":"0_1_11","id":"0_1_11_2","text":"大兴安岭市","value":"大兴安岭市","open":true},{"pId":"0_1_11","id":"0_1_11_3","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_1_11","id":"0_1_11_4","text":"鹤港市","value":"鹤港市","open":true},{"pId":"0_1_11","id":"0_1_11_5","text":"黑河市","value":"黑河市","open":true},{"pId":"0_1_11","id":"0_1_11_6","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_1_11","id":"0_1_11_7","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_1_11","id":"0_1_11_8","text":"七台河市","value":"七台河市","open":true},{"pId":"0_1_11","id":"0_1_11_9","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_1_11","id":"0_1_11_10","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_1_11","id":"0_1_11_11","text":"绥化市","value":"绥化市","open":true},{"pId":"0_1_11","id":"0_1_11_12","text":"伊春市","value":"伊春市","open":true},{"pId":"0_1","id":"0_1_12","text":"湖北省( 共16个 )","value":"湖北省","open":true},{"pId":"0_1_12","id":"0_1_12_0","text":"鄂州市","value":"鄂州市","open":true},{"pId":"0_1_12","id":"0_1_12_1","text":"恩施土家族苗族自治州","value":"恩施土家族苗族自治州","open":true},{"pId":"0_1_12","id":"0_1_12_2","text":"黄冈市","value":"黄冈市","open":true},{"pId":"0_1_12","id":"0_1_12_3","text":"黄石市","value":"黄石市","open":true},{"pId":"0_1_12","id":"0_1_12_4","text":"荆门市","value":"荆门市","open":true},{"pId":"0_1_12","id":"0_1_12_5","text":"荆州市","value":"荆州市","open":true},{"pId":"0_1_12","id":"0_1_12_6","text":"神农架市","value":"神农架市","open":true},{"pId":"0_1_12","id":"0_1_12_7","text":"十堰市","value":"十堰市","open":true},{"pId":"0_1_12","id":"0_1_12_8","text":"随州市","value":"随州市","open":true},{"pId":"0_1_12","id":"0_1_12_9","text":"天门市","value":"天门市","open":true},{"pId":"0_1_12","id":"0_1_12_10","text":"武汉市","value":"武汉市","open":true},{"pId":"0_1_12","id":"0_1_12_11","text":"咸宁市","value":"咸宁市","open":true},{"pId":"0_1_12","id":"0_1_12_12","text":"襄樊市","value":"襄樊市","open":true},{"pId":"0_1_12","id":"0_1_12_13","text":"襄阳市","value":"襄阳市","open":true},{"pId":"0_1_12","id":"0_1_12_14","text":"孝感市","value":"孝感市","open":true},{"pId":"0_1_12","id":"0_1_12_15","text":"宜昌市","value":"宜昌市","open":true},{"pId":"0_1","id":"0_1_13","text":"湖南省( 共15个 )","value":"湖南省","open":true},{"pId":"0_1_13","id":"0_1_13_0","text":"常德市","value":"常德市","open":true},{"pId":"0_1_13","id":"0_1_13_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_1_13","id":"0_1_13_2","text":"郴州市","value":"郴州市","open":true},{"pId":"0_1_13","id":"0_1_13_3","text":"衡阳市","value":"衡阳市","open":true},{"pId":"0_1_13","id":"0_1_13_4","text":"怀化市","value":"怀化市","open":true},{"pId":"0_1_13","id":"0_1_13_5","text":"娄底市","value":"娄底市","open":true},{"pId":"0_1_13","id":"0_1_13_6","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_1_13","id":"0_1_13_7","text":"湘潭市","value":"湘潭市","open":true},{"pId":"0_1_13","id":"0_1_13_8","text":"湘西市","value":"湘西市","open":true},{"pId":"0_1_13","id":"0_1_13_9","text":"湘西土家族苗族自治州","value":"湘西土家族苗族自治州","open":true},{"pId":"0_1_13","id":"0_1_13_10","text":"益阳市","value":"益阳市","open":true},{"pId":"0_1_13","id":"0_1_13_11","text":"永州市","value":"永州市","open":true},{"pId":"0_1_13","id":"0_1_13_12","text":"岳阳市","value":"岳阳市","open":true},{"pId":"0_1_13","id":"0_1_13_13","text":"张家界市","value":"张家界市","open":true},{"pId":"0_1_13","id":"0_1_13_14","text":"株洲市","value":"株洲市","open":true},{"pId":"0_1","id":"0_1_14","text":"吉林省( 共10个 )","value":"吉林省","open":true},{"pId":"0_1_14","id":"0_1_14_0","text":"白城市","value":"白城市","open":true},{"pId":"0_1_14","id":"0_1_14_1","text":"白山市","value":"白山市","open":true},{"pId":"0_1_14","id":"0_1_14_2","text":"长春市","value":"长春市","open":true},{"pId":"0_1_14","id":"0_1_14_3","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_14","id":"0_1_14_4","text":"吉林市","value":"吉林市","open":true},{"pId":"0_1_14","id":"0_1_14_5","text":"辽源市","value":"辽源市","open":true},{"pId":"0_1_14","id":"0_1_14_6","text":"四平市","value":"四平市","open":true},{"pId":"0_1_14","id":"0_1_14_7","text":"松原市","value":"松原市","open":true},{"pId":"0_1_14","id":"0_1_14_8","text":"通化市","value":"通化市","open":true},{"pId":"0_1_14","id":"0_1_14_9","text":"延边朝鲜族自治州","value":"延边朝鲜族自治州","open":true},{"pId":"0_1","id":"0_1_15","text":"江苏省( 共13个 )","value":"江苏省","open":true},{"pId":"0_1_15","id":"0_1_15_0","text":"常州市","value":"常州市","open":true},{"pId":"0_1_15","id":"0_1_15_1","text":"淮安市","value":"淮安市","open":true},{"pId":"0_1_15","id":"0_1_15_2","text":"连云港市","value":"连云港市","open":true},{"pId":"0_1_15","id":"0_1_15_3","text":"南京市","value":"南京市","open":true},{"pId":"0_1_15","id":"0_1_15_4","text":"南通市","value":"南通市","open":true},{"pId":"0_1_15","id":"0_1_15_5","text":"苏州市","value":"苏州市","open":true},{"pId":"0_1_15","id":"0_1_15_6","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_1_15","id":"0_1_15_7","text":"泰州市","value":"泰州市","open":true},{"pId":"0_1_15","id":"0_1_15_8","text":"无锡市","value":"无锡市","open":true},{"pId":"0_1_15","id":"0_1_15_9","text":"徐州市","value":"徐州市","open":true},{"pId":"0_1_15","id":"0_1_15_10","text":"盐城市","value":"盐城市","open":true},{"pId":"0_1_15","id":"0_1_15_11","text":"扬州市","value":"扬州市","open":true},{"pId":"0_1_15","id":"0_1_15_12","text":"镇江市","value":"镇江市","open":true},{"pId":"0_1","id":"0_1_16","text":"江西省( 共10个 )","value":"江西省","open":true},{"pId":"0_1_16","id":"0_1_16_0","text":"抚州市","value":"抚州市","open":true},{"pId":"0_1_16","id":"0_1_16_1","text":"赣州市","value":"赣州市","open":true},{"pId":"0_1_16","id":"0_1_16_2","text":"景德镇市","value":"景德镇市","open":true},{"pId":"0_1_16","id":"0_1_16_3","text":"九江市","value":"九江市","open":true},{"pId":"0_1_16","id":"0_1_16_4","text":"南昌市","value":"南昌市","open":true},{"pId":"0_1_16","id":"0_1_16_5","text":"萍乡市","value":"萍乡市","open":true},{"pId":"0_1_16","id":"0_1_16_6","text":"上饶市","value":"上饶市","open":true},{"pId":"0_1_16","id":"0_1_16_7","text":"新余市","value":"新余市","open":true},{"pId":"0_1_16","id":"0_1_16_8","text":"宜春市","value":"宜春市","open":true},{"pId":"0_1_16","id":"0_1_16_9","text":"鹰潭市","value":"鹰潭市","open":true},{"pId":"0_1","id":"0_1_17","text":"辽宁省( 共14个 )","value":"辽宁省","open":true},{"pId":"0_1_17","id":"0_1_17_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_1_17","id":"0_1_17_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_1_17","id":"0_1_17_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_1_17","id":"0_1_17_3","text":"大连市","value":"大连市","open":true},{"pId":"0_1_17","id":"0_1_17_4","text":"丹东市","value":"丹东市","open":true},{"pId":"0_1_17","id":"0_1_17_5","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_1_17","id":"0_1_17_6","text":"阜新市","value":"阜新市","open":true},{"pId":"0_1_17","id":"0_1_17_7","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_1_17","id":"0_1_17_8","text":"锦州市","value":"锦州市","open":true},{"pId":"0_1_17","id":"0_1_17_9","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_1_17","id":"0_1_17_10","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_1_17","id":"0_1_17_11","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_1_17","id":"0_1_17_12","text":"铁岭市","value":"铁岭市","open":true},{"pId":"0_1_17","id":"0_1_17_13","text":"营口市","value":"营口市","open":true},{"pId":"0_1","id":"0_1_18","text":"内蒙古( 共10个 )","value":"内蒙古","open":true},{"pId":"0_1_18","id":"0_1_18_0","text":"包头市","value":"包头市","open":true},{"pId":"0_1_18","id":"0_1_18_1","text":"赤峰市","value":"赤峰市","open":true},{"pId":"0_1_18","id":"0_1_18_2","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_1_18","id":"0_1_18_3","text":"呼和浩特市","value":"呼和浩特市","open":true},{"pId":"0_1_18","id":"0_1_18_4","text":"呼伦贝尔市","value":"呼伦贝尔市","open":true},{"pId":"0_1_18","id":"0_1_18_5","text":"通辽市","value":"通辽市","open":true},{"pId":"0_1_18","id":"0_1_18_6","text":"乌海市","value":"乌海市","open":true},{"pId":"0_1_18","id":"0_1_18_7","text":"锡林郭勒市","value":"锡林郭勒市","open":true},{"pId":"0_1_18","id":"0_1_18_8","text":"兴安市","value":"兴安市","open":true},{"pId":"0_1_18","id":"0_1_18_9","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_19","text":"宁夏回族自治区( 共5个 )","value":"宁夏回族自治区","open":true},{"pId":"0_1_19","id":"0_1_19_0","text":"固原市","value":"固原市","open":true},{"pId":"0_1_19","id":"0_1_19_1","text":"石嘴山市","value":"石嘴山市","open":true},{"pId":"0_1_19","id":"0_1_19_2","text":"吴忠市","value":"吴忠市","open":true},{"pId":"0_1_19","id":"0_1_19_3","text":"银川市","value":"银川市","open":true},{"pId":"0_1_19","id":"0_1_19_4","text":"中卫市","value":"中卫市","open":true},{"pId":"0_1","id":"0_1_20","text":"青海省( 共4个 )","value":"青海省","open":true},{"pId":"0_1_20","id":"0_1_20_0","text":"海东地区","value":"海东地区","open":true},{"pId":"0_1_20","id":"0_1_20_1","text":"海南藏族自治州","value":"海南藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_2","text":"海西蒙古族藏族自治州","value":"海西蒙古族藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_3","text":"西宁市","value":"西宁市","open":true},{"pId":"0_1","id":"0_1_21","text":"山东省( 共17个 )","value":"山东省","open":true},{"pId":"0_1_21","id":"0_1_21_0","text":"滨州市","value":"滨州市","open":true},{"pId":"0_1_21","id":"0_1_21_1","text":"德州市","value":"德州市","open":true},{"pId":"0_1_21","id":"0_1_21_2","text":"东营市","value":"东营市","open":true},{"pId":"0_1_21","id":"0_1_21_3","text":"菏泽市","value":"菏泽市","open":true},{"pId":"0_1_21","id":"0_1_21_4","text":"济南市","value":"济南市","open":true},{"pId":"0_1_21","id":"0_1_21_5","text":"济宁市","value":"济宁市","open":true},{"pId":"0_1_21","id":"0_1_21_6","text":"莱芜市","value":"莱芜市","open":true},{"pId":"0_1_21","id":"0_1_21_7","text":"聊城市","value":"聊城市","open":true},{"pId":"0_1_21","id":"0_1_21_8","text":"临沂市","value":"临沂市","open":true},{"pId":"0_1_21","id":"0_1_21_9","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_21","id":"0_1_21_10","text":"日照市","value":"日照市","open":true},{"pId":"0_1_21","id":"0_1_21_11","text":"泰安市","value":"泰安市","open":true},{"pId":"0_1_21","id":"0_1_21_12","text":"威海市","value":"威海市","open":true},{"pId":"0_1_21","id":"0_1_21_13","text":"潍坊市","value":"潍坊市","open":true},{"pId":"0_1_21","id":"0_1_21_14","text":"烟台市","value":"烟台市","open":true},{"pId":"0_1_21","id":"0_1_21_15","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_1_21","id":"0_1_21_16","text":"淄博市","value":"淄博市","open":true},{"pId":"0_1","id":"0_1_22","text":"山西省( 共12个 )","value":"山西省","open":true},{"pId":"0_1_22","id":"0_1_22_0","text":"长治市","value":"长治市","open":true},{"pId":"0_1_22","id":"0_1_22_1","text":"大同市","value":"大同市","open":true},{"pId":"0_1_22","id":"0_1_22_2","text":"晋城市","value":"晋城市","open":true},{"pId":"0_1_22","id":"0_1_22_3","text":"晋中市","value":"晋中市","open":true},{"pId":"0_1_22","id":"0_1_22_4","text":"临汾市","value":"临汾市","open":true},{"pId":"0_1_22","id":"0_1_22_5","text":"吕梁市","value":"吕梁市","open":true},{"pId":"0_1_22","id":"0_1_22_6","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_22","id":"0_1_22_7","text":"朔州市","value":"朔州市","open":true},{"pId":"0_1_22","id":"0_1_22_8","text":"太原市","value":"太原市","open":true},{"pId":"0_1_22","id":"0_1_22_9","text":"忻州市","value":"忻州市","open":true},{"pId":"0_1_22","id":"0_1_22_10","text":"阳泉市","value":"阳泉市","open":true},{"pId":"0_1_22","id":"0_1_22_11","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_23","text":"陕西省( 共9个 )","value":"陕西省","open":true},{"pId":"0_1_23","id":"0_1_23_0","text":"安康市","value":"安康市","open":true},{"pId":"0_1_23","id":"0_1_23_1","text":"宝鸡市","value":"宝鸡市","open":true},{"pId":"0_1_23","id":"0_1_23_2","text":"汉中市","value":"汉中市","open":true},{"pId":"0_1_23","id":"0_1_23_3","text":"商洛市","value":"商洛市","open":true},{"pId":"0_1_23","id":"0_1_23_4","text":"渭南市","value":"渭南市","open":true},{"pId":"0_1_23","id":"0_1_23_5","text":"西安市","value":"西安市","open":true},{"pId":"0_1_23","id":"0_1_23_6","text":"咸阳市","value":"咸阳市","open":true},{"pId":"0_1_23","id":"0_1_23_7","text":"延安市","value":"延安市","open":true},{"pId":"0_1_23","id":"0_1_23_8","text":"榆林市","value":"榆林市","open":true},{"pId":"0_1","id":"0_1_24","text":"上海市( 共19个 )","value":"上海市","open":true},{"pId":"0_1_24","id":"0_1_24_0","text":"宝山区","value":"宝山区","open":true},{"pId":"0_1_24","id":"0_1_24_1","text":"长宁区","value":"长宁区","open":true},{"pId":"0_1_24","id":"0_1_24_2","text":"崇明县","value":"崇明县","open":true},{"pId":"0_1_24","id":"0_1_24_3","text":"奉贤区","value":"奉贤区","open":true},{"pId":"0_1_24","id":"0_1_24_4","text":"虹口区","value":"虹口区","open":true},{"pId":"0_1_24","id":"0_1_24_5","text":"黄浦区","value":"黄浦区","open":true},{"pId":"0_1_24","id":"0_1_24_6","text":"嘉定区","value":"嘉定区","open":true},{"pId":"0_1_24","id":"0_1_24_7","text":"金山区","value":"金山区","open":true},{"pId":"0_1_24","id":"0_1_24_8","text":"静安区","value":"静安区","open":true},{"pId":"0_1_24","id":"0_1_24_9","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_24","id":"0_1_24_10","text":"闵行区","value":"闵行区","open":true},{"pId":"0_1_24","id":"0_1_24_11","text":"普陀区","value":"普陀区","open":true},{"pId":"0_1_24","id":"0_1_24_12","text":"浦东新区","value":"浦东新区","open":true},{"pId":"0_1_24","id":"0_1_24_13","text":"青浦区","value":"青浦区","open":true},{"pId":"0_1_24","id":"0_1_24_14","text":"上海市区","value":"上海市区","open":true},{"pId":"0_1_24","id":"0_1_24_15","text":"松江区","value":"松江区","open":true},{"pId":"0_1_24","id":"0_1_24_16","text":"徐汇区","value":"徐汇区","open":true},{"pId":"0_1_24","id":"0_1_24_17","text":"杨浦区","value":"杨浦区","open":true},{"pId":"0_1_24","id":"0_1_24_18","text":"闸北区","value":"闸北区","open":true},{"pId":"0_1","id":"0_1_25","text":"四川省( 共21个 )","value":"四川省","open":true},{"pId":"0_1_25","id":"0_1_25_0","text":"阿坝藏族羌族自治州","value":"阿坝藏族羌族自治州","open":true},{"pId":"0_1_25","id":"0_1_25_1","text":"巴中市","value":"巴中市","open":true},{"pId":"0_1_25","id":"0_1_25_2","text":"成都市","value":"成都市","open":true},{"pId":"0_1_25","id":"0_1_25_3","text":"达州市","value":"达州市","open":true},{"pId":"0_1_25","id":"0_1_25_4","text":"德阳市","value":"德阳市","open":true},{"pId":"0_1_25","id":"0_1_25_5","text":"甘孜市","value":"甘孜市","open":true},{"pId":"0_1_25","id":"0_1_25_6","text":"广安市","value":"广安市","open":true},{"pId":"0_1_25","id":"0_1_25_7","text":"广元市","value":"广元市","open":true},{"pId":"0_1_25","id":"0_1_25_8","text":"乐山市","value":"乐山市","open":true},{"pId":"0_1_25","id":"0_1_25_9","text":"凉山市","value":"凉山市","open":true},{"pId":"0_1_25","id":"0_1_25_10","text":"泸州市","value":"泸州市","open":true},{"pId":"0_1_25","id":"0_1_25_11","text":"眉山市","value":"眉山市","open":true},{"pId":"0_1_25","id":"0_1_25_12","text":"绵阳市","value":"绵阳市","open":true},{"pId":"0_1_25","id":"0_1_25_13","text":"南充市","value":"南充市","open":true},{"pId":"0_1_25","id":"0_1_25_14","text":"内江市","value":"内江市","open":true},{"pId":"0_1_25","id":"0_1_25_15","text":"攀枝花市","value":"攀枝花市","open":true},{"pId":"0_1_25","id":"0_1_25_16","text":"遂宁市","value":"遂宁市","open":true},{"pId":"0_1_25","id":"0_1_25_17","text":"雅安市","value":"雅安市","open":true},{"pId":"0_1_25","id":"0_1_25_18","text":"宜宾市","value":"宜宾市","open":true},{"pId":"0_1_25","id":"0_1_25_19","text":"资阳市","value":"资阳市","open":true},{"pId":"0_1_25","id":"0_1_25_20","text":"自贡市","value":"自贡市","open":true},{"pId":"0_1","id":"0_1_26","text":"台湾( 共1个 )","value":"台湾","open":true},{"pId":"0_1_26","id":"0_1_26_0","text":"台北市","value":"台北市","open":true},{"pId":"0_1","id":"0_1_27","text":"天津市( 共1个 )","value":"天津市","open":true},{"pId":"0_1_27","id":"0_1_27_0","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1","id":"0_1_28","text":"西藏自治区( 共2个 )","value":"西藏自治区","open":true},{"pId":"0_1_28","id":"0_1_28_0","text":"阿里市","value":"阿里市","open":true},{"pId":"0_1_28","id":"0_1_28_1","text":"日喀则市","value":"日喀则市","open":true},{"pId":"0_1","id":"0_1_29","text":"香港特别行政区( 共1个 )","value":"香港特别行政区","open":true},{"pId":"0_1_29","id":"0_1_29_0","text":"香港","value":"香港","open":true},{"pId":"0_1","id":"0_1_30","text":"新疆维吾尔族自治区( 共11个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_1_30","id":"0_1_30_0","text":"巴音郭楞市","value":"巴音郭楞市","open":true},{"pId":"0_1_30","id":"0_1_30_1","text":"哈密市","value":"哈密市","open":true},{"pId":"0_1_30","id":"0_1_30_2","text":"和田市","value":"和田市","open":true},{"pId":"0_1_30","id":"0_1_30_3","text":"喀什地区","value":"喀什地区","open":true},{"pId":"0_1_30","id":"0_1_30_4","text":"克拉玛依市","value":"克拉玛依市","open":true},{"pId":"0_1_30","id":"0_1_30_5","text":"克孜勒苏柯州","value":"克孜勒苏柯州","open":true},{"pId":"0_1_30","id":"0_1_30_6","text":"石河子市","value":"石河子市","open":true},{"pId":"0_1_30","id":"0_1_30_7","text":"塔城市","value":"塔城市","open":true},{"pId":"0_1_30","id":"0_1_30_8","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_1_30","id":"0_1_30_9","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_1_30","id":"0_1_30_10","text":"伊犁市","value":"伊犁市","open":true},{"pId":"0_1","id":"0_1_31","text":"云南省( 共12个 )","value":"云南省","open":true},{"pId":"0_1_31","id":"0_1_31_0","text":"保山市","value":"保山市","open":true},{"pId":"0_1_31","id":"0_1_31_1","text":"楚雄彝族自治州","value":"楚雄彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_2","text":"大理白族自治州","value":"大理白族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_3","text":"红河哈尼族彝族自治州","value":"红河哈尼族彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_4","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_31","id":"0_1_31_5","text":"丽江市","value":"丽江市","open":true},{"pId":"0_1_31","id":"0_1_31_6","text":"临沧市","value":"临沧市","open":true},{"pId":"0_1_31","id":"0_1_31_7","text":"曲靖市","value":"曲靖市","open":true},{"pId":"0_1_31","id":"0_1_31_8","text":"思茅市","value":"思茅市","open":true},{"pId":"0_1_31","id":"0_1_31_9","text":"文山市","value":"文山市","open":true},{"pId":"0_1_31","id":"0_1_31_10","text":"玉溪市","value":"玉溪市","open":true},{"pId":"0_1_31","id":"0_1_31_11","text":"昭通市","value":"昭通市","open":true},{"pId":"0_1","id":"0_1_32","text":"浙江省( 共12个 )","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_1_32","id":"0_1_32_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_1_32","id":"0_1_32_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_1_32","id":"0_1_32_3","text":"金华市","value":"金华市","open":true},{"pId":"0_1_32","id":"0_1_32_4","text":"丽水市","value":"丽水市","open":true},{"pId":"0_1_32","id":"0_1_32_5","text":"宁波市","value":"宁波市","open":true},{"pId":"0_1_32","id":"0_1_32_6","text":"衢州市","value":"衢州市","open":true},{"pId":"0_1_32","id":"0_1_32_7","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_1_32","id":"0_1_32_8","text":"台州市","value":"台州市","open":true},{"pId":"0_1_32","id":"0_1_32_9","text":"温州市","value":"温州市","open":true},{"pId":"0_1_32","id":"0_1_32_10","text":"浙江省","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_11","text":"舟山市","value":"舟山市","open":true},{"pId":"0_1","id":"0_1_33","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_1_33","id":"0_1_33_0","text":"重庆市区","value":"重庆市区","open":true}] + TREEITEMS: [{"pId":"0","id":"0_0","text":"( 共25个 )","value":"","open":true},{"pId":"0_0","id":"0_0_0","text":"安徽省( 共1个 )","value":"安徽省","open":true},{"pId":"0_0_0","id":"0_0_0_0","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_0","id":"0_0_1","text":"北京市( 共6个 )","value":"北京市","open":true},{"pId":"0_0_1","id":"0_0_1_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_0_1","id":"0_0_1_1","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_0_1","id":"0_0_1_2","text":"东城区","value":"东城区","open":true},{"pId":"0_0_1","id":"0_0_1_3","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_0_1","id":"0_0_1_4","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_0_1","id":"0_0_1_5","text":"石景山区","value":"石景山区","open":true},{"pId":"0_0","id":"0_0_2","text":"福建省( 共2个 )","value":"福建省","open":true},{"pId":"0_0_2","id":"0_0_2_0","text":"莆田市","value":"莆田市","open":true},{"pId":"0_0_2","id":"0_0_2_1","text":"泉州市","value":"泉州市","open":true},{"pId":"0_0","id":"0_0_3","text":"甘肃省( 共1个 )","value":"甘肃省","open":true},{"pId":"0_0_3","id":"0_0_3_0","text":"兰州市","value":"兰州市","open":true},{"pId":"0_0","id":"0_0_4","text":"广东省( 共5个 )","value":"广东省","open":true},{"pId":"0_0_4","id":"0_0_4_0","text":"东莞市","value":"东莞市","open":true},{"pId":"0_0_4","id":"0_0_4_1","text":"广州市","value":"广州市","open":true},{"pId":"0_0_4","id":"0_0_4_2","text":"惠州市","value":"惠州市","open":true},{"pId":"0_0_4","id":"0_0_4_3","text":"深圳市","value":"深圳市","open":true},{"pId":"0_0_4","id":"0_0_4_4","text":"珠海市","value":"珠海市","open":true},{"pId":"0_0","id":"0_0_5","text":"广西壮族自治区( 共1个 )","value":"广西壮族自治区","open":true},{"pId":"0_0_5","id":"0_0_5_0","text":"南宁市","value":"南宁市","open":true},{"pId":"0_0","id":"0_0_6","text":"河北省( 共2个 )","value":"河北省","open":true},{"pId":"0_0_6","id":"0_0_6_0","text":"保定市","value":"保定市","open":true},{"pId":"0_0_6","id":"0_0_6_1","text":"邢台市","value":"邢台市","open":true},{"pId":"0_0","id":"0_0_7","text":"河南省( 共1个 )","value":"河南省","open":true},{"pId":"0_0_7","id":"0_0_7_0","text":"郑州市","value":"郑州市","open":true},{"pId":"0_0","id":"0_0_8","text":"黑龙江省( 共7个 )","value":"黑龙江省","open":true},{"pId":"0_0_8","id":"0_0_8_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_0_8","id":"0_0_8_1","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_0_8","id":"0_0_8_2","text":"鸡西市","value":"鸡西市","open":true},{"pId":"0_0_8","id":"0_0_8_3","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_0_8","id":"0_0_8_4","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_0_8","id":"0_0_8_5","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_0_8","id":"0_0_8_6","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_0","id":"0_0_9","text":"湖北省( 共1个 )","value":"湖北省","open":true},{"pId":"0_0_9","id":"0_0_9_0","text":"武汉市","value":"武汉市","open":true},{"pId":"0_0","id":"0_0_10","text":"湖南省( 共3个 )","value":"湖南省","open":true},{"pId":"0_0_10","id":"0_0_10_0","text":"常德市","value":"常德市","open":true},{"pId":"0_0_10","id":"0_0_10_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_0_10","id":"0_0_10_2","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_0","id":"0_0_11","text":"吉林省( 共4个 )","value":"吉林省","open":true},{"pId":"0_0_11","id":"0_0_11_0","text":"白山市","value":"白山市","open":true},{"pId":"0_0_11","id":"0_0_11_1","text":"长春市","value":"长春市","open":true},{"pId":"0_0_11","id":"0_0_11_2","text":"松原市","value":"松原市","open":true},{"pId":"0_0_11","id":"0_0_11_3","text":"通化市","value":"通化市","open":true},{"pId":"0_0","id":"0_0_12","text":"江苏省( 共8个 )","value":"江苏省","open":true},{"pId":"0_0_12","id":"0_0_12_0","text":"常州市","value":"常州市","open":true},{"pId":"0_0_12","id":"0_0_12_1","text":"南京市","value":"南京市","open":true},{"pId":"0_0_12","id":"0_0_12_2","text":"南通市","value":"南通市","open":true},{"pId":"0_0_12","id":"0_0_12_3","text":"苏州市","value":"苏州市","open":true},{"pId":"0_0_12","id":"0_0_12_4","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_0_12","id":"0_0_12_5","text":"泰州市","value":"泰州市","open":true},{"pId":"0_0_12","id":"0_0_12_6","text":"无锡市","value":"无锡市","open":true},{"pId":"0_0_12","id":"0_0_12_7","text":"盐城市","value":"盐城市","open":true},{"pId":"0_0","id":"0_0_13","text":"辽宁省( 共11个 )","value":"辽宁省","open":true},{"pId":"0_0_13","id":"0_0_13_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_0_13","id":"0_0_13_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_0_13","id":"0_0_13_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_0_13","id":"0_0_13_3","text":"大连市","value":"大连市","open":true},{"pId":"0_0_13","id":"0_0_13_4","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_0_13","id":"0_0_13_5","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_0_13","id":"0_0_13_6","text":"锦州市","value":"锦州市","open":true},{"pId":"0_0_13","id":"0_0_13_7","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_0_13","id":"0_0_13_8","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_0_13","id":"0_0_13_9","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_0_13","id":"0_0_13_10","text":"营口市","value":"营口市","open":true},{"pId":"0_0","id":"0_0_14","text":"内蒙古( 共1个 )","value":"内蒙古","open":true},{"pId":"0_0_14","id":"0_0_14_0","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_0","id":"0_0_15","text":"宁夏回族自治区( 共1个 )","value":"宁夏回族自治区","open":true},{"pId":"0_0_15","id":"0_0_15_0","text":"银川市","value":"银川市","open":true},{"pId":"0_0","id":"0_0_16","text":"山东省( 共7个 )","value":"山东省","open":true},{"pId":"0_0_16","id":"0_0_16_0","text":"济南市","value":"济南市","open":true},{"pId":"0_0_16","id":"0_0_16_1","text":"济宁市","value":"济宁市","open":true},{"pId":"0_0_16","id":"0_0_16_2","text":"聊城市","value":"聊城市","open":true},{"pId":"0_0_16","id":"0_0_16_3","text":"临沂市","value":"临沂市","open":true},{"pId":"0_0_16","id":"0_0_16_4","text":"青岛市","value":"青岛市","open":true},{"pId":"0_0_16","id":"0_0_16_5","text":"烟台市","value":"烟台市","open":true},{"pId":"0_0_16","id":"0_0_16_6","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_0","id":"0_0_17","text":"山西省( 共1个 )","value":"山西省","open":true},{"pId":"0_0_17","id":"0_0_17_0","text":"太原市","value":"太原市","open":true},{"pId":"0_0","id":"0_0_18","text":"陕西省( 共1个 )","value":"陕西省","open":true},{"pId":"0_0_18","id":"0_0_18_0","text":"西安市","value":"西安市","open":true},{"pId":"0_0","id":"0_0_19","text":"上海市( 共1个 )","value":"上海市","open":true},{"pId":"0_0_19","id":"0_0_19_0","text":"上海市区","value":"上海市区","open":true},{"pId":"0_0","id":"0_0_20","text":"四川省( 共1个 )","value":"四川省","open":true},{"pId":"0_0_20","id":"0_0_20_0","text":"成都市","value":"成都市","open":true},{"pId":"0_0","id":"0_0_21","text":"新疆维吾尔族自治区( 共2个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_0_21","id":"0_0_21_0","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_0_21","id":"0_0_21_1","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_0","id":"0_0_22","text":"云南省( 共1个 )","value":"云南省","open":true},{"pId":"0_0_22","id":"0_0_22_0","text":"昆明市","value":"昆明市","open":true},{"pId":"0_0","id":"0_0_23","text":"浙江省( 共5个 )","value":"浙江省","open":true},{"pId":"0_0_23","id":"0_0_23_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_0_23","id":"0_0_23_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_0_23","id":"0_0_23_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_0_23","id":"0_0_23_3","text":"宁波市","value":"宁波市","open":true},{"pId":"0_0_23","id":"0_0_23_4","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_0","id":"0_0_24","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_0_24","id":"0_0_24_0","text":"重庆市区","value":"重庆市区","open":true},{"pId":"0","id":"0_1","text":"中国( 共34个 )","value":"中国","open":true},{"pId":"0_1","id":"0_1_0","text":"安徽省( 共19个 )","value":"安徽省","open":true},{"pId":"0_1_0","id":"0_1_0_0","text":"安庆市","value":"安庆市","open":true},{"pId":"0_1_0","id":"0_1_0_1","text":"蚌埠市","value":"蚌埠市","open":true},{"pId":"0_1_0","id":"0_1_0_2","text":"亳州市","value":"亳州市","open":true},{"pId":"0_1_0","id":"0_1_0_3","text":"巢湖市","value":"巢湖市","open":true},{"pId":"0_1_0","id":"0_1_0_4","text":"池州市","value":"池州市","open":true},{"pId":"0_1_0","id":"0_1_0_5","text":"滁州市","value":"滁州市","open":true},{"pId":"0_1_0","id":"0_1_0_6","text":"阜阳市","value":"阜阳市","open":true},{"pId":"0_1_0","id":"0_1_0_7","text":"毫州市","value":"毫州市","open":true},{"pId":"0_1_0","id":"0_1_0_8","text":"合肥市","value":"合肥市","open":true},{"pId":"0_1_0","id":"0_1_0_9","text":"淮北市","value":"淮北市","open":true},{"pId":"0_1_0","id":"0_1_0_10","text":"淮南市","value":"淮南市","open":true},{"pId":"0_1_0","id":"0_1_0_11","text":"黄山市","value":"黄山市","open":true},{"pId":"0_1_0","id":"0_1_0_12","text":"六安市","value":"六安市","open":true},{"pId":"0_1_0","id":"0_1_0_13","text":"马鞍山市","value":"马鞍山市","open":true},{"pId":"0_1_0","id":"0_1_0_14","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_0","id":"0_1_0_15","text":"宿州市","value":"宿州市","open":true},{"pId":"0_1_0","id":"0_1_0_16","text":"铜陵市","value":"铜陵市","open":true},{"pId":"0_1_0","id":"0_1_0_17","text":"芜湖市","value":"芜湖市","open":true},{"pId":"0_1_0","id":"0_1_0_18","text":"宣城市","value":"宣城市","open":true},{"pId":"0_1","id":"0_1_1","text":"澳门特别行政区( 共1个 )","value":"澳门特别行政区","open":true},{"pId":"0_1_1","id":"0_1_1_0","text":"澳门","value":"澳门","open":true},{"pId":"0_1","id":"0_1_2","text":"北京市( 共17个 )","value":"北京市","open":true},{"pId":"0_1_2","id":"0_1_2_0","text":"北京市区","value":"北京市区","open":true},{"pId":"0_1_2","id":"0_1_2_1","text":"昌平区","value":"昌平区","open":true},{"pId":"0_1_2","id":"0_1_2_2","text":"朝阳区","value":"朝阳区","open":true},{"pId":"0_1_2","id":"0_1_2_3","text":"大兴区","value":"大兴区","open":true},{"pId":"0_1_2","id":"0_1_2_4","text":"东城区","value":"东城区","open":true},{"pId":"0_1_2","id":"0_1_2_5","text":"房山区","value":"房山区","open":true},{"pId":"0_1_2","id":"0_1_2_6","text":"丰台区","value":"丰台区","open":true},{"pId":"0_1_2","id":"0_1_2_7","text":"海淀区","value":"海淀区","open":true},{"pId":"0_1_2","id":"0_1_2_8","text":"海淀区4内","value":"海淀区4内","open":true},{"pId":"0_1_2","id":"0_1_2_9","text":"海淀区4外","value":"海淀区4外","open":true},{"pId":"0_1_2","id":"0_1_2_10","text":"门头沟区","value":"门头沟区","open":true},{"pId":"0_1_2","id":"0_1_2_11","text":"平谷区","value":"平谷区","open":true},{"pId":"0_1_2","id":"0_1_2_12","text":"石景山区","value":"石景山区","open":true},{"pId":"0_1_2","id":"0_1_2_13","text":"顺义区","value":"顺义区","open":true},{"pId":"0_1_2","id":"0_1_2_14","text":"通州区","value":"通州区","open":true},{"pId":"0_1_2","id":"0_1_2_15","text":"西城区","value":"西城区","open":true},{"pId":"0_1_2","id":"0_1_2_16","text":"西城区 ","value":"西城区 ","open":true},{"pId":"0_1","id":"0_1_3","text":"福建省( 共9个 )","value":"福建省","open":true},{"pId":"0_1_3","id":"0_1_3_0","text":"福州市","value":"福州市","open":true},{"pId":"0_1_3","id":"0_1_3_1","text":"龙岩市","value":"龙岩市","open":true},{"pId":"0_1_3","id":"0_1_3_2","text":"南平市","value":"南平市","open":true},{"pId":"0_1_3","id":"0_1_3_3","text":"宁德市","value":"宁德市","open":true},{"pId":"0_1_3","id":"0_1_3_4","text":"莆田市","value":"莆田市","open":true},{"pId":"0_1_3","id":"0_1_3_5","text":"泉州市","value":"泉州市","open":true},{"pId":"0_1_3","id":"0_1_3_6","text":"三明市","value":"三明市","open":true},{"pId":"0_1_3","id":"0_1_3_7","text":"厦门市","value":"厦门市","open":true},{"pId":"0_1_3","id":"0_1_3_8","text":"漳州市","value":"漳州市","open":true},{"pId":"0_1","id":"0_1_4","text":"甘肃省( 共12个 )","value":"甘肃省","open":true},{"pId":"0_1_4","id":"0_1_4_0","text":"白银市","value":"白银市","open":true},{"pId":"0_1_4","id":"0_1_4_1","text":"嘉峪关市","value":"嘉峪关市","open":true},{"pId":"0_1_4","id":"0_1_4_2","text":"金昌市","value":"金昌市","open":true},{"pId":"0_1_4","id":"0_1_4_3","text":"酒泉市","value":"酒泉市","open":true},{"pId":"0_1_4","id":"0_1_4_4","text":"兰州市","value":"兰州市","open":true},{"pId":"0_1_4","id":"0_1_4_5","text":"陇南市","value":"陇南市","open":true},{"pId":"0_1_4","id":"0_1_4_6","text":"平凉市","value":"平凉市","open":true},{"pId":"0_1_4","id":"0_1_4_7","text":"庆阳市","value":"庆阳市","open":true},{"pId":"0_1_4","id":"0_1_4_8","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_4","id":"0_1_4_9","text":"天水市","value":"天水市","open":true},{"pId":"0_1_4","id":"0_1_4_10","text":"武威市","value":"武威市","open":true},{"pId":"0_1_4","id":"0_1_4_11","text":"张掖市","value":"张掖市","open":true},{"pId":"0_1","id":"0_1_5","text":"广东省( 共21个 )","value":"广东省","open":true},{"pId":"0_1_5","id":"0_1_5_0","text":"潮州市","value":"潮州市","open":true},{"pId":"0_1_5","id":"0_1_5_1","text":"东莞市","value":"东莞市","open":true},{"pId":"0_1_5","id":"0_1_5_2","text":"佛山市","value":"佛山市","open":true},{"pId":"0_1_5","id":"0_1_5_3","text":"广州市","value":"广州市","open":true},{"pId":"0_1_5","id":"0_1_5_4","text":"河源市","value":"河源市","open":true},{"pId":"0_1_5","id":"0_1_5_5","text":"惠州市","value":"惠州市","open":true},{"pId":"0_1_5","id":"0_1_5_6","text":"江门市","value":"江门市","open":true},{"pId":"0_1_5","id":"0_1_5_7","text":"揭阳市","value":"揭阳市","open":true},{"pId":"0_1_5","id":"0_1_5_8","text":"茂名市","value":"茂名市","open":true},{"pId":"0_1_5","id":"0_1_5_9","text":"梅州市","value":"梅州市","open":true},{"pId":"0_1_5","id":"0_1_5_10","text":"清远市","value":"清远市","open":true},{"pId":"0_1_5","id":"0_1_5_11","text":"汕头市","value":"汕头市","open":true},{"pId":"0_1_5","id":"0_1_5_12","text":"汕尾市","value":"汕尾市","open":true},{"pId":"0_1_5","id":"0_1_5_13","text":"韶关市","value":"韶关市","open":true},{"pId":"0_1_5","id":"0_1_5_14","text":"深圳市","value":"深圳市","open":true},{"pId":"0_1_5","id":"0_1_5_15","text":"阳江市","value":"阳江市","open":true},{"pId":"0_1_5","id":"0_1_5_16","text":"云浮市","value":"云浮市","open":true},{"pId":"0_1_5","id":"0_1_5_17","text":"湛江市","value":"湛江市","open":true},{"pId":"0_1_5","id":"0_1_5_18","text":"肇庆市","value":"肇庆市","open":true},{"pId":"0_1_5","id":"0_1_5_19","text":"中山市","value":"中山市","open":true},{"pId":"0_1_5","id":"0_1_5_20","text":"珠海市","value":"珠海市","open":true},{"pId":"0_1","id":"0_1_6","text":"广西壮族自治区( 共14个 )","value":"广西壮族自治区","open":true},{"pId":"0_1_6","id":"0_1_6_0","text":"百色市","value":"百色市","open":true},{"pId":"0_1_6","id":"0_1_6_1","text":"北海市","value":"北海市","open":true},{"pId":"0_1_6","id":"0_1_6_2","text":"崇左市","value":"崇左市","open":true},{"pId":"0_1_6","id":"0_1_6_3","text":"防城港市","value":"防城港市","open":true},{"pId":"0_1_6","id":"0_1_6_4","text":"桂林市","value":"桂林市","open":true},{"pId":"0_1_6","id":"0_1_6_5","text":"贵港市","value":"贵港市","open":true},{"pId":"0_1_6","id":"0_1_6_6","text":"河池市","value":"河池市","open":true},{"pId":"0_1_6","id":"0_1_6_7","text":"贺州市","value":"贺州市","open":true},{"pId":"0_1_6","id":"0_1_6_8","text":"来宾市","value":"来宾市","open":true},{"pId":"0_1_6","id":"0_1_6_9","text":"柳州市","value":"柳州市","open":true},{"pId":"0_1_6","id":"0_1_6_10","text":"南宁市","value":"南宁市","open":true},{"pId":"0_1_6","id":"0_1_6_11","text":"钦州市","value":"钦州市","open":true},{"pId":"0_1_6","id":"0_1_6_12","text":"梧州市","value":"梧州市","open":true},{"pId":"0_1_6","id":"0_1_6_13","text":"玉林市","value":"玉林市","open":true},{"pId":"0_1","id":"0_1_7","text":"贵州省( 共9个 )","value":"贵州省","open":true},{"pId":"0_1_7","id":"0_1_7_0","text":"安顺市","value":"安顺市","open":true},{"pId":"0_1_7","id":"0_1_7_1","text":"毕节地区","value":"毕节地区","open":true},{"pId":"0_1_7","id":"0_1_7_2","text":"贵阳市","value":"贵阳市","open":true},{"pId":"0_1_7","id":"0_1_7_3","text":"六盘水市","value":"六盘水市","open":true},{"pId":"0_1_7","id":"0_1_7_4","text":"黔东南州","value":"黔东南州","open":true},{"pId":"0_1_7","id":"0_1_7_5","text":"黔南州","value":"黔南州","open":true},{"pId":"0_1_7","id":"0_1_7_6","text":"黔西南市","value":"黔西南市","open":true},{"pId":"0_1_7","id":"0_1_7_7","text":"铜仁地区","value":"铜仁地区","open":true},{"pId":"0_1_7","id":"0_1_7_8","text":"遵义市","value":"遵义市","open":true},{"pId":"0_1","id":"0_1_8","text":"海南省( 共2个 )","value":"海南省","open":true},{"pId":"0_1_8","id":"0_1_8_0","text":"海口市","value":"海口市","open":true},{"pId":"0_1_8","id":"0_1_8_1","text":"三亚市","value":"三亚市","open":true},{"pId":"0_1","id":"0_1_9","text":"河北省( 共12个 )","value":"河北省","open":true},{"pId":"0_1_9","id":"0_1_9_0","text":"保定市","value":"保定市","open":true},{"pId":"0_1_9","id":"0_1_9_1","text":"沧州市","value":"沧州市","open":true},{"pId":"0_1_9","id":"0_1_9_2","text":"承德市","value":"承德市","open":true},{"pId":"0_1_9","id":"0_1_9_3","text":"邯郸市","value":"邯郸市","open":true},{"pId":"0_1_9","id":"0_1_9_4","text":"衡水市","value":"衡水市","open":true},{"pId":"0_1_9","id":"0_1_9_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_9","id":"0_1_9_6","text":"秦皇岛市","value":"秦皇岛市","open":true},{"pId":"0_1_9","id":"0_1_9_7","text":"石家庄市","value":"石家庄市","open":true},{"pId":"0_1_9","id":"0_1_9_8","text":"唐山市","value":"唐山市","open":true},{"pId":"0_1_9","id":"0_1_9_9","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1_9","id":"0_1_9_10","text":"邢台市","value":"邢台市","open":true},{"pId":"0_1_9","id":"0_1_9_11","text":"张家口市","value":"张家口市","open":true},{"pId":"0_1","id":"0_1_10","text":"河南省( 共19个 )","value":"河南省","open":true},{"pId":"0_1_10","id":"0_1_10_0","text":"安阳市","value":"安阳市","open":true},{"pId":"0_1_10","id":"0_1_10_1","text":"鹤壁市","value":"鹤壁市","open":true},{"pId":"0_1_10","id":"0_1_10_2","text":"济源市","value":"济源市","open":true},{"pId":"0_1_10","id":"0_1_10_3","text":"焦作市","value":"焦作市","open":true},{"pId":"0_1_10","id":"0_1_10_4","text":"开封市","value":"开封市","open":true},{"pId":"0_1_10","id":"0_1_10_5","text":"廊坊市","value":"廊坊市","open":true},{"pId":"0_1_10","id":"0_1_10_6","text":"洛阳市","value":"洛阳市","open":true},{"pId":"0_1_10","id":"0_1_10_7","text":"漯河市","value":"漯河市","open":true},{"pId":"0_1_10","id":"0_1_10_8","text":"南阳市","value":"南阳市","open":true},{"pId":"0_1_10","id":"0_1_10_9","text":"平顶山市","value":"平顶山市","open":true},{"pId":"0_1_10","id":"0_1_10_10","text":"濮阳市","value":"濮阳市","open":true},{"pId":"0_1_10","id":"0_1_10_11","text":"三门峡市","value":"三门峡市","open":true},{"pId":"0_1_10","id":"0_1_10_12","text":"商丘市","value":"商丘市","open":true},{"pId":"0_1_10","id":"0_1_10_13","text":"新乡市","value":"新乡市","open":true},{"pId":"0_1_10","id":"0_1_10_14","text":"信阳市","value":"信阳市","open":true},{"pId":"0_1_10","id":"0_1_10_15","text":"许昌市","value":"许昌市","open":true},{"pId":"0_1_10","id":"0_1_10_16","text":"郑州市","value":"郑州市","open":true},{"pId":"0_1_10","id":"0_1_10_17","text":"周口市","value":"周口市","open":true},{"pId":"0_1_10","id":"0_1_10_18","text":"驻马店市","value":"驻马店市","open":true},{"pId":"0_1","id":"0_1_11","text":"黑龙江省( 共13个 )","value":"黑龙江省","open":true},{"pId":"0_1_11","id":"0_1_11_0","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_11","id":"0_1_11_1","text":"大兴安岭地区","value":"大兴安岭地区","open":true},{"pId":"0_1_11","id":"0_1_11_2","text":"大兴安岭市","value":"大兴安岭市","open":true},{"pId":"0_1_11","id":"0_1_11_3","text":"哈尔滨市","value":"哈尔滨市","open":true},{"pId":"0_1_11","id":"0_1_11_4","text":"鹤港市","value":"鹤港市","open":true},{"pId":"0_1_11","id":"0_1_11_5","text":"黑河市","value":"黑河市","open":true},{"pId":"0_1_11","id":"0_1_11_6","text":"佳木斯市","value":"佳木斯市","open":true},{"pId":"0_1_11","id":"0_1_11_7","text":"牡丹江市","value":"牡丹江市","open":true},{"pId":"0_1_11","id":"0_1_11_8","text":"七台河市","value":"七台河市","open":true},{"pId":"0_1_11","id":"0_1_11_9","text":"齐齐哈尔市","value":"齐齐哈尔市","open":true},{"pId":"0_1_11","id":"0_1_11_10","text":"双鸭山市","value":"双鸭山市","open":true},{"pId":"0_1_11","id":"0_1_11_11","text":"绥化市","value":"绥化市","open":true},{"pId":"0_1_11","id":"0_1_11_12","text":"伊春市","value":"伊春市","open":true},{"pId":"0_1","id":"0_1_12","text":"湖北省( 共16个 )","value":"湖北省","open":true},{"pId":"0_1_12","id":"0_1_12_0","text":"鄂州市","value":"鄂州市","open":true},{"pId":"0_1_12","id":"0_1_12_1","text":"恩施土家族苗族自治州","value":"恩施土家族苗族自治州","open":true},{"pId":"0_1_12","id":"0_1_12_2","text":"黄冈市","value":"黄冈市","open":true},{"pId":"0_1_12","id":"0_1_12_3","text":"黄石市","value":"黄石市","open":true},{"pId":"0_1_12","id":"0_1_12_4","text":"荆门市","value":"荆门市","open":true},{"pId":"0_1_12","id":"0_1_12_5","text":"荆州市","value":"荆州市","open":true},{"pId":"0_1_12","id":"0_1_12_6","text":"神农架市","value":"神农架市","open":true},{"pId":"0_1_12","id":"0_1_12_7","text":"十堰市","value":"十堰市","open":true},{"pId":"0_1_12","id":"0_1_12_8","text":"随州市","value":"随州市","open":true},{"pId":"0_1_12","id":"0_1_12_9","text":"天门市","value":"天门市","open":true},{"pId":"0_1_12","id":"0_1_12_10","text":"武汉市","value":"武汉市","open":true},{"pId":"0_1_12","id":"0_1_12_11","text":"咸宁市","value":"咸宁市","open":true},{"pId":"0_1_12","id":"0_1_12_12","text":"襄樊市","value":"襄樊市","open":true},{"pId":"0_1_12","id":"0_1_12_13","text":"襄阳市","value":"襄阳市","open":true},{"pId":"0_1_12","id":"0_1_12_14","text":"孝感市","value":"孝感市","open":true},{"pId":"0_1_12","id":"0_1_12_15","text":"宜昌市","value":"宜昌市","open":true},{"pId":"0_1","id":"0_1_13","text":"湖南省( 共15个 )","value":"湖南省","open":true},{"pId":"0_1_13","id":"0_1_13_0","text":"常德市","value":"常德市","open":true},{"pId":"0_1_13","id":"0_1_13_1","text":"长沙市","value":"长沙市","open":true},{"pId":"0_1_13","id":"0_1_13_2","text":"郴州市","value":"郴州市","open":true},{"pId":"0_1_13","id":"0_1_13_3","text":"衡阳市","value":"衡阳市","open":true},{"pId":"0_1_13","id":"0_1_13_4","text":"怀化市","value":"怀化市","open":true},{"pId":"0_1_13","id":"0_1_13_5","text":"娄底市","value":"娄底市","open":true},{"pId":"0_1_13","id":"0_1_13_6","text":"邵阳市","value":"邵阳市","open":true},{"pId":"0_1_13","id":"0_1_13_7","text":"湘潭市","value":"湘潭市","open":true},{"pId":"0_1_13","id":"0_1_13_8","text":"湘西市","value":"湘西市","open":true},{"pId":"0_1_13","id":"0_1_13_9","text":"湘西土家族苗族自治州","value":"湘西土家族苗族自治州","open":true},{"pId":"0_1_13","id":"0_1_13_10","text":"益阳市","value":"益阳市","open":true},{"pId":"0_1_13","id":"0_1_13_11","text":"永州市","value":"永州市","open":true},{"pId":"0_1_13","id":"0_1_13_12","text":"岳阳市","value":"岳阳市","open":true},{"pId":"0_1_13","id":"0_1_13_13","text":"张家界市","value":"张家界市","open":true},{"pId":"0_1_13","id":"0_1_13_14","text":"株洲市","value":"株洲市","open":true},{"pId":"0_1","id":"0_1_14","text":"吉林省( 共10个 )","value":"吉林省","open":true},{"pId":"0_1_14","id":"0_1_14_0","text":"白城市","value":"白城市","open":true},{"pId":"0_1_14","id":"0_1_14_1","text":"白山市","value":"白山市","open":true},{"pId":"0_1_14","id":"0_1_14_2","text":"长春市","value":"长春市","open":true},{"pId":"0_1_14","id":"0_1_14_3","text":"大庆市","value":"大庆市","open":true},{"pId":"0_1_14","id":"0_1_14_4","text":"吉林市","value":"吉林市","open":true},{"pId":"0_1_14","id":"0_1_14_5","text":"辽源市","value":"辽源市","open":true},{"pId":"0_1_14","id":"0_1_14_6","text":"四平市","value":"四平市","open":true},{"pId":"0_1_14","id":"0_1_14_7","text":"松原市","value":"松原市","open":true},{"pId":"0_1_14","id":"0_1_14_8","text":"通化市","value":"通化市","open":true},{"pId":"0_1_14","id":"0_1_14_9","text":"延边朝鲜族自治州","value":"延边朝鲜族自治州","open":true},{"pId":"0_1","id":"0_1_15","text":"江苏省( 共13个 )","value":"江苏省","open":true},{"pId":"0_1_15","id":"0_1_15_0","text":"常州市","value":"常州市","open":true},{"pId":"0_1_15","id":"0_1_15_1","text":"淮安市","value":"淮安市","open":true},{"pId":"0_1_15","id":"0_1_15_2","text":"连云港市","value":"连云港市","open":true},{"pId":"0_1_15","id":"0_1_15_3","text":"南京市","value":"南京市","open":true},{"pId":"0_1_15","id":"0_1_15_4","text":"南通市","value":"南通市","open":true},{"pId":"0_1_15","id":"0_1_15_5","text":"苏州市","value":"苏州市","open":true},{"pId":"0_1_15","id":"0_1_15_6","text":"宿迁市","value":"宿迁市","open":true},{"pId":"0_1_15","id":"0_1_15_7","text":"泰州市","value":"泰州市","open":true},{"pId":"0_1_15","id":"0_1_15_8","text":"无锡市","value":"无锡市","open":true},{"pId":"0_1_15","id":"0_1_15_9","text":"徐州市","value":"徐州市","open":true},{"pId":"0_1_15","id":"0_1_15_10","text":"盐城市","value":"盐城市","open":true},{"pId":"0_1_15","id":"0_1_15_11","text":"扬州市","value":"扬州市","open":true},{"pId":"0_1_15","id":"0_1_15_12","text":"镇江市","value":"镇江市","open":true},{"pId":"0_1","id":"0_1_16","text":"江西省( 共10个 )","value":"江西省","open":true},{"pId":"0_1_16","id":"0_1_16_0","text":"抚州市","value":"抚州市","open":true},{"pId":"0_1_16","id":"0_1_16_1","text":"赣州市","value":"赣州市","open":true},{"pId":"0_1_16","id":"0_1_16_2","text":"景德镇市","value":"景德镇市","open":true},{"pId":"0_1_16","id":"0_1_16_3","text":"九江市","value":"九江市","open":true},{"pId":"0_1_16","id":"0_1_16_4","text":"南昌市","value":"南昌市","open":true},{"pId":"0_1_16","id":"0_1_16_5","text":"萍乡市","value":"萍乡市","open":true},{"pId":"0_1_16","id":"0_1_16_6","text":"上饶市","value":"上饶市","open":true},{"pId":"0_1_16","id":"0_1_16_7","text":"新余市","value":"新余市","open":true},{"pId":"0_1_16","id":"0_1_16_8","text":"宜春市","value":"宜春市","open":true},{"pId":"0_1_16","id":"0_1_16_9","text":"鹰潭市","value":"鹰潭市","open":true},{"pId":"0_1","id":"0_1_17","text":"辽宁省( 共14个 )","value":"辽宁省","open":true},{"pId":"0_1_17","id":"0_1_17_0","text":"鞍山市","value":"鞍山市","open":true},{"pId":"0_1_17","id":"0_1_17_1","text":"本溪市","value":"本溪市","open":true},{"pId":"0_1_17","id":"0_1_17_2","text":"朝阳市","value":"朝阳市","open":true},{"pId":"0_1_17","id":"0_1_17_3","text":"大连市","value":"大连市","open":true},{"pId":"0_1_17","id":"0_1_17_4","text":"丹东市","value":"丹东市","open":true},{"pId":"0_1_17","id":"0_1_17_5","text":"抚顺市","value":"抚顺市","open":true},{"pId":"0_1_17","id":"0_1_17_6","text":"阜新市","value":"阜新市","open":true},{"pId":"0_1_17","id":"0_1_17_7","text":"葫芦岛市","value":"葫芦岛市","open":true},{"pId":"0_1_17","id":"0_1_17_8","text":"锦州市","value":"锦州市","open":true},{"pId":"0_1_17","id":"0_1_17_9","text":"辽阳市","value":"辽阳市","open":true},{"pId":"0_1_17","id":"0_1_17_10","text":"盘锦市","value":"盘锦市","open":true},{"pId":"0_1_17","id":"0_1_17_11","text":"沈阳市","value":"沈阳市","open":true},{"pId":"0_1_17","id":"0_1_17_12","text":"铁岭市","value":"铁岭市","open":true},{"pId":"0_1_17","id":"0_1_17_13","text":"营口市","value":"营口市","open":true},{"pId":"0_1","id":"0_1_18","text":"内蒙古( 共10个 )","value":"内蒙古","open":true},{"pId":"0_1_18","id":"0_1_18_0","text":"包头市","value":"包头市","open":true},{"pId":"0_1_18","id":"0_1_18_1","text":"赤峰市","value":"赤峰市","open":true},{"pId":"0_1_18","id":"0_1_18_2","text":"鄂尔多斯市","value":"鄂尔多斯市","open":true},{"pId":"0_1_18","id":"0_1_18_3","text":"呼和浩特市","value":"呼和浩特市","open":true},{"pId":"0_1_18","id":"0_1_18_4","text":"呼伦贝尔市","value":"呼伦贝尔市","open":true},{"pId":"0_1_18","id":"0_1_18_5","text":"通辽市","value":"通辽市","open":true},{"pId":"0_1_18","id":"0_1_18_6","text":"乌海市","value":"乌海市","open":true},{"pId":"0_1_18","id":"0_1_18_7","text":"锡林郭勒市","value":"锡林郭勒市","open":true},{"pId":"0_1_18","id":"0_1_18_8","text":"兴安市","value":"兴安市","open":true},{"pId":"0_1_18","id":"0_1_18_9","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_19","text":"宁夏回族自治区( 共5个 )","value":"宁夏回族自治区","open":true},{"pId":"0_1_19","id":"0_1_19_0","text":"固原市","value":"固原市","open":true},{"pId":"0_1_19","id":"0_1_19_1","text":"石嘴山市","value":"石嘴山市","open":true},{"pId":"0_1_19","id":"0_1_19_2","text":"吴忠市","value":"吴忠市","open":true},{"pId":"0_1_19","id":"0_1_19_3","text":"银川市","value":"银川市","open":true},{"pId":"0_1_19","id":"0_1_19_4","text":"中卫市","value":"中卫市","open":true},{"pId":"0_1","id":"0_1_20","text":"青海省( 共4个 )","value":"青海省","open":true},{"pId":"0_1_20","id":"0_1_20_0","text":"海东地区","value":"海东地区","open":true},{"pId":"0_1_20","id":"0_1_20_1","text":"海南藏族自治州","value":"海南藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_2","text":"海西蒙古族藏族自治州","value":"海西蒙古族藏族自治州","open":true},{"pId":"0_1_20","id":"0_1_20_3","text":"西宁市","value":"西宁市","open":true},{"pId":"0_1","id":"0_1_21","text":"山东省( 共17个 )","value":"山东省","open":true},{"pId":"0_1_21","id":"0_1_21_0","text":"滨州市","value":"滨州市","open":true},{"pId":"0_1_21","id":"0_1_21_1","text":"德州市","value":"德州市","open":true},{"pId":"0_1_21","id":"0_1_21_2","text":"东营市","value":"东营市","open":true},{"pId":"0_1_21","id":"0_1_21_3","text":"菏泽市","value":"菏泽市","open":true},{"pId":"0_1_21","id":"0_1_21_4","text":"济南市","value":"济南市","open":true},{"pId":"0_1_21","id":"0_1_21_5","text":"济宁市","value":"济宁市","open":true},{"pId":"0_1_21","id":"0_1_21_6","text":"莱芜市","value":"莱芜市","open":true},{"pId":"0_1_21","id":"0_1_21_7","text":"聊城市","value":"聊城市","open":true},{"pId":"0_1_21","id":"0_1_21_8","text":"临沂市","value":"临沂市","open":true},{"pId":"0_1_21","id":"0_1_21_9","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_21","id":"0_1_21_10","text":"日照市","value":"日照市","open":true},{"pId":"0_1_21","id":"0_1_21_11","text":"泰安市","value":"泰安市","open":true},{"pId":"0_1_21","id":"0_1_21_12","text":"威海市","value":"威海市","open":true},{"pId":"0_1_21","id":"0_1_21_13","text":"潍坊市","value":"潍坊市","open":true},{"pId":"0_1_21","id":"0_1_21_14","text":"烟台市","value":"烟台市","open":true},{"pId":"0_1_21","id":"0_1_21_15","text":"枣庄市","value":"枣庄市","open":true},{"pId":"0_1_21","id":"0_1_21_16","text":"淄博市","value":"淄博市","open":true},{"pId":"0_1","id":"0_1_22","text":"山西省( 共12个 )","value":"山西省","open":true},{"pId":"0_1_22","id":"0_1_22_0","text":"长治市","value":"长治市","open":true},{"pId":"0_1_22","id":"0_1_22_1","text":"大同市","value":"大同市","open":true},{"pId":"0_1_22","id":"0_1_22_2","text":"晋城市","value":"晋城市","open":true},{"pId":"0_1_22","id":"0_1_22_3","text":"晋中市","value":"晋中市","open":true},{"pId":"0_1_22","id":"0_1_22_4","text":"临汾市","value":"临汾市","open":true},{"pId":"0_1_22","id":"0_1_22_5","text":"吕梁市","value":"吕梁市","open":true},{"pId":"0_1_22","id":"0_1_22_6","text":"青岛市","value":"青岛市","open":true},{"pId":"0_1_22","id":"0_1_22_7","text":"朔州市","value":"朔州市","open":true},{"pId":"0_1_22","id":"0_1_22_8","text":"太原市","value":"太原市","open":true},{"pId":"0_1_22","id":"0_1_22_9","text":"忻州市","value":"忻州市","open":true},{"pId":"0_1_22","id":"0_1_22_10","text":"阳泉市","value":"阳泉市","open":true},{"pId":"0_1_22","id":"0_1_22_11","text":"运城市","value":"运城市","open":true},{"pId":"0_1","id":"0_1_23","text":"陕西省( 共9个 )","value":"陕西省","open":true},{"pId":"0_1_23","id":"0_1_23_0","text":"安康市","value":"安康市","open":true},{"pId":"0_1_23","id":"0_1_23_1","text":"宝鸡市","value":"宝鸡市","open":true},{"pId":"0_1_23","id":"0_1_23_2","text":"汉中市","value":"汉中市","open":true},{"pId":"0_1_23","id":"0_1_23_3","text":"商洛市","value":"商洛市","open":true},{"pId":"0_1_23","id":"0_1_23_4","text":"渭南市","value":"渭南市","open":true},{"pId":"0_1_23","id":"0_1_23_5","text":"西安市","value":"西安市","open":true},{"pId":"0_1_23","id":"0_1_23_6","text":"咸阳市","value":"咸阳市","open":true},{"pId":"0_1_23","id":"0_1_23_7","text":"延安市","value":"延安市","open":true},{"pId":"0_1_23","id":"0_1_23_8","text":"榆林市","value":"榆林市","open":true},{"pId":"0_1","id":"0_1_24","text":"上海市( 共19个 )","value":"上海市","open":true},{"pId":"0_1_24","id":"0_1_24_0","text":"宝山区","value":"宝山区","open":true},{"pId":"0_1_24","id":"0_1_24_1","text":"长宁区","value":"长宁区","open":true},{"pId":"0_1_24","id":"0_1_24_2","text":"崇明县","value":"崇明县","open":true},{"pId":"0_1_24","id":"0_1_24_3","text":"奉贤区","value":"奉贤区","open":true},{"pId":"0_1_24","id":"0_1_24_4","text":"虹口区","value":"虹口区","open":true},{"pId":"0_1_24","id":"0_1_24_5","text":"黄浦区","value":"黄浦区","open":true},{"pId":"0_1_24","id":"0_1_24_6","text":"嘉定区","value":"嘉定区","open":true},{"pId":"0_1_24","id":"0_1_24_7","text":"金山区","value":"金山区","open":true},{"pId":"0_1_24","id":"0_1_24_8","text":"静安区","value":"静安区","open":true},{"pId":"0_1_24","id":"0_1_24_9","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_24","id":"0_1_24_10","text":"闵行区","value":"闵行区","open":true},{"pId":"0_1_24","id":"0_1_24_11","text":"普陀区","value":"普陀区","open":true},{"pId":"0_1_24","id":"0_1_24_12","text":"浦东新区","value":"浦东新区","open":true},{"pId":"0_1_24","id":"0_1_24_13","text":"青浦区","value":"青浦区","open":true},{"pId":"0_1_24","id":"0_1_24_14","text":"上海市区","value":"上海市区","open":true},{"pId":"0_1_24","id":"0_1_24_15","text":"松江区","value":"松江区","open":true},{"pId":"0_1_24","id":"0_1_24_16","text":"徐汇区","value":"徐汇区","open":true},{"pId":"0_1_24","id":"0_1_24_17","text":"杨浦区","value":"杨浦区","open":true},{"pId":"0_1_24","id":"0_1_24_18","text":"闸北区","value":"闸北区","open":true},{"pId":"0_1","id":"0_1_25","text":"四川省( 共21个 )","value":"四川省","open":true},{"pId":"0_1_25","id":"0_1_25_0","text":"阿坝藏族羌族自治州","value":"阿坝藏族羌族自治州","open":true},{"pId":"0_1_25","id":"0_1_25_1","text":"巴中市","value":"巴中市","open":true},{"pId":"0_1_25","id":"0_1_25_2","text":"成都市","value":"成都市","open":true},{"pId":"0_1_25","id":"0_1_25_3","text":"达州市","value":"达州市","open":true},{"pId":"0_1_25","id":"0_1_25_4","text":"德阳市","value":"德阳市","open":true},{"pId":"0_1_25","id":"0_1_25_5","text":"甘孜市","value":"甘孜市","open":true},{"pId":"0_1_25","id":"0_1_25_6","text":"广安市","value":"广安市","open":true},{"pId":"0_1_25","id":"0_1_25_7","text":"广元市","value":"广元市","open":true},{"pId":"0_1_25","id":"0_1_25_8","text":"乐山市","value":"乐山市","open":true},{"pId":"0_1_25","id":"0_1_25_9","text":"凉山市","value":"凉山市","open":true},{"pId":"0_1_25","id":"0_1_25_10","text":"泸州市","value":"泸州市","open":true},{"pId":"0_1_25","id":"0_1_25_11","text":"眉山市","value":"眉山市","open":true},{"pId":"0_1_25","id":"0_1_25_12","text":"绵阳市","value":"绵阳市","open":true},{"pId":"0_1_25","id":"0_1_25_13","text":"南充市","value":"南充市","open":true},{"pId":"0_1_25","id":"0_1_25_14","text":"内江市","value":"内江市","open":true},{"pId":"0_1_25","id":"0_1_25_15","text":"攀枝花市","value":"攀枝花市","open":true},{"pId":"0_1_25","id":"0_1_25_16","text":"遂宁市","value":"遂宁市","open":true},{"pId":"0_1_25","id":"0_1_25_17","text":"雅安市","value":"雅安市","open":true},{"pId":"0_1_25","id":"0_1_25_18","text":"宜宾市","value":"宜宾市","open":true},{"pId":"0_1_25","id":"0_1_25_19","text":"资阳市","value":"资阳市","open":true},{"pId":"0_1_25","id":"0_1_25_20","text":"自贡市","value":"自贡市","open":true},{"pId":"0_1","id":"0_1_26","text":"台湾( 共1个 )","value":"台湾","open":true},{"pId":"0_1_26","id":"0_1_26_0","text":"台北市","value":"台北市","open":true},{"pId":"0_1","id":"0_1_27","text":"天津市( 共1个 )","value":"天津市","open":true},{"pId":"0_1_27","id":"0_1_27_0","text":"天津市区","value":"天津市区","open":true},{"pId":"0_1","id":"0_1_28","text":"西藏自治区( 共2个 )","value":"西藏自治区","open":true},{"pId":"0_1_28","id":"0_1_28_0","text":"阿里市","value":"阿里市","open":true},{"pId":"0_1_28","id":"0_1_28_1","text":"日喀则市","value":"日喀则市","open":true},{"pId":"0_1","id":"0_1_29","text":"香港特别行政区( 共1个 )","value":"香港特别行政区","open":true},{"pId":"0_1_29","id":"0_1_29_0","text":"香港","value":"香港","open":true},{"pId":"0_1","id":"0_1_30","text":"新疆维吾尔族自治区( 共11个 )","value":"新疆维吾尔族自治区","open":true},{"pId":"0_1_30","id":"0_1_30_0","text":"巴音郭楞市","value":"巴音郭楞市","open":true},{"pId":"0_1_30","id":"0_1_30_1","text":"哈密市","value":"哈密市","open":true},{"pId":"0_1_30","id":"0_1_30_2","text":"和田市","value":"和田市","open":true},{"pId":"0_1_30","id":"0_1_30_3","text":"喀什地区","value":"喀什地区","open":true},{"pId":"0_1_30","id":"0_1_30_4","text":"克拉玛依市","value":"克拉玛依市","open":true},{"pId":"0_1_30","id":"0_1_30_5","text":"克孜勒苏柯州","value":"克孜勒苏柯州","open":true},{"pId":"0_1_30","id":"0_1_30_6","text":"石河子市","value":"石河子市","open":true},{"pId":"0_1_30","id":"0_1_30_7","text":"塔城市","value":"塔城市","open":true},{"pId":"0_1_30","id":"0_1_30_8","text":"吐鲁番地区","value":"吐鲁番地区","open":true},{"pId":"0_1_30","id":"0_1_30_9","text":"乌鲁木齐","value":"乌鲁木齐","open":true},{"pId":"0_1_30","id":"0_1_30_10","text":"伊犁市","value":"伊犁市","open":true},{"pId":"0_1","id":"0_1_31","text":"云南省( 共12个 )","value":"云南省","open":true},{"pId":"0_1_31","id":"0_1_31_0","text":"保山市","value":"保山市","open":true},{"pId":"0_1_31","id":"0_1_31_1","text":"楚雄彝族自治州","value":"楚雄彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_2","text":"大理白族自治州","value":"大理白族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_3","text":"红河哈尼族彝族自治州","value":"红河哈尼族彝族自治州","open":true},{"pId":"0_1_31","id":"0_1_31_4","text":"昆明市","value":"昆明市","open":true},{"pId":"0_1_31","id":"0_1_31_5","text":"丽江市","value":"丽江市","open":true},{"pId":"0_1_31","id":"0_1_31_6","text":"临沧市","value":"临沧市","open":true},{"pId":"0_1_31","id":"0_1_31_7","text":"曲靖市","value":"曲靖市","open":true},{"pId":"0_1_31","id":"0_1_31_8","text":"思茅市","value":"思茅市","open":true},{"pId":"0_1_31","id":"0_1_31_9","text":"文山市","value":"文山市","open":true},{"pId":"0_1_31","id":"0_1_31_10","text":"玉溪市","value":"玉溪市","open":true},{"pId":"0_1_31","id":"0_1_31_11","text":"昭通市","value":"昭通市","open":true},{"pId":"0_1","id":"0_1_32","text":"浙江省( 共12个 )","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_0","text":"杭州市","value":"杭州市","open":true},{"pId":"0_1_32","id":"0_1_32_1","text":"湖州市","value":"湖州市","open":true},{"pId":"0_1_32","id":"0_1_32_2","text":"嘉兴市","value":"嘉兴市","open":true},{"pId":"0_1_32","id":"0_1_32_3","text":"金华市","value":"金华市","open":true},{"pId":"0_1_32","id":"0_1_32_4","text":"丽水市","value":"丽水市","open":true},{"pId":"0_1_32","id":"0_1_32_5","text":"宁波市","value":"宁波市","open":true},{"pId":"0_1_32","id":"0_1_32_6","text":"衢州市","value":"衢州市","open":true},{"pId":"0_1_32","id":"0_1_32_7","text":"绍兴市","value":"绍兴市","open":true},{"pId":"0_1_32","id":"0_1_32_8","text":"台州市","value":"台州市","open":true},{"pId":"0_1_32","id":"0_1_32_9","text":"温州市","value":"温州市","open":true},{"pId":"0_1_32","id":"0_1_32_10","text":"浙江省","value":"浙江省","open":true},{"pId":"0_1_32","id":"0_1_32_11","text":"舟山市","value":"舟山市","open":true},{"pId":"0_1","id":"0_1_33","text":"重庆市( 共1个 )","value":"重庆市","open":true},{"pId":"0_1_33","id":"0_1_33_0","text":"重庆市区","value":"重庆市区","open":true}], + + TREE:[{id: -1, pId: -2, value: "根目录", text: "根目录"}, + {id: 1, pId: -1, value: "第一级目录1", text: "第一级目录1"}, + {id: 11, pId: 1, value: "第二级文件1", text: "第二级文件1"}, + {id: 12, pId: 1, value: "第二级目录2", text: "第二级目录2"}, + {id: 121, pId: 12, value: "第三级目录1", text: "第三级目录1"}, + {id: 122, pId: 12, value: "第三级文件1", text: "第三级文件1"}, + {id: 1211, pId: 121, value: "第四级目录1", text: "第四级目录1"}, + {id: 12111, pId: 1211, value: "第五级文件1", text: "第五级文件1"}, + {id: 2, pId: -1, value: "第一级目录2", text: "第一级目录2"}, + {id: 21, pId: 2, value: "第二级目录3", text: "第二级目录3"}, + {id: 22, pId: 2, value: "第二级文件2", text: "第二级文件2"}, + {id: 211, pId: 21, value: "第三级目录2", text: "第三级目录2"}, + {id: 212, pId: 21, value: "第三级文件2", text: "第三级文件2"}, + {id: 2111, pId: 211, value: "第四级文件1", text: "第四级文件1"}] }; diff --git a/docs/icon/arrow left right.png b/docs/icon/arrow left right.png new file mode 100644 index 000000000..2a87a9b46 Binary files /dev/null and b/docs/icon/arrow left right.png differ diff --git a/docs/icon/radio.png b/docs/icon/radio.png new file mode 100644 index 000000000..489346819 Binary files /dev/null and b/docs/icon/radio.png differ diff --git a/docs/icon/slider.png b/docs/icon/slider.png new file mode 100644 index 000000000..0211186da Binary files /dev/null and b/docs/icon/slider.png differ diff --git a/docs/icon/双向箭头.png b/docs/icon/双向箭头.png new file mode 100644 index 000000000..c816d0394 Binary files /dev/null and b/docs/icon/双向箭头.png differ diff --git a/docs/index.html b/docs/index.html index 0db30acc5..4c893684b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,33 +1,31 @@ - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + + + - + + -
+
+ \ No newline at end of file diff --git a/docs/polyfill.js b/docs/polyfill.js index 1da80799f..f493c89a5 100644 --- a/docs/polyfill.js +++ b/docs/polyfill.js @@ -1,93 +1,93 @@ -if(![].indexOf){ - /** - * 检查指定的值是否在数组中 - * @param {Object} o 要检查的值 - * @return {Number} o在数组中的索引(如果不在数组中则返回-1) - */ - Array.prototype.indexOf = function (o) { - for (var i = 0, len = this.length; i < len; i++) { - if (_.isEqual(o, this[i])) { - return i; - } - } - return -1; - } -} -if(![].lastIndexOf){ - /** - * 检查指定的值是否在数组中 - * ie67不支持数组的这个方法 - * @param {Object} o 要检查的值 - * @return {Number} o在数组中的索引(如果不在数组中则返回-1) - */ - Array.prototype.lastIndexOf = function (o) { - for (var len = this.length, i = len - 1; i >= 0; i--) { - if (_.isEqual(o, this[i])) { - return i; - } - } - return -1; - } -}/** - * 特殊情况 - * Created by wang on 15/6/23. - */ -//解决console未定义问题 guy -window.console = window.console || (function () { - var c = {}; - c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile - = c.clear = c.exception = c.trace = c.assert = function () { - }; - return c; - })(); -/* - * 前端缓存 - */ -window.localStorage || (window.localStorage = { - items: {}, - setItem: function (k, v) { - BI.Cache.addCookie(k, v); - }, - getItem: function (k) { - return BI.Cache.getCookie(k); - }, - removeItem: function (k) { - BI.Cache.deleteCookie(k); - }, - key: function () { - - }, - clear: function () { - this.items = {}; - } -});//修复ie9下sort方法的bug -!function (window) { - var ua = window.navigator.userAgent.toLowerCase(), - reg = /msie|applewebkit.+safari/; - if (reg.test(ua)) { - var _sort = Array.prototype.sort; - Array.prototype.sort = function (fn) { - if (!!fn && typeof fn === 'function') { - if (this.length < 2) { - return this; - } - var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0; - for (; i < l; i++) { - for (j = i + 1; j < l; j++) { - t = fn.call(this, this[i], this[j]); - r = (typeof t === 'number' ? t : - !!t ? 1 : 0) > 0; - if (r === true) { - tmp = this[i]; - this[i] = this[j]; - this[j] = tmp; - } - } - } - return this; - } else { - return _sort.call(this); - } - }; - } +if(![].indexOf){ + /** + * 检查指定的值是否在数组中 + * @param {Object} o 要检查的值 + * @return {Number} o在数组中的索引(如果不在数组中则返回-1) + */ + Array.prototype.indexOf = function (o) { + for (var i = 0, len = this.length; i < len; i++) { + if (_.isEqual(o, this[i])) { + return i; + } + } + return -1; + } +} +if(![].lastIndexOf){ + /** + * 检查指定的值是否在数组中 + * ie67不支持数组的这个方法 + * @param {Object} o 要检查的值 + * @return {Number} o在数组中的索引(如果不在数组中则返回-1) + */ + Array.prototype.lastIndexOf = function (o) { + for (var len = this.length, i = len - 1; i >= 0; i--) { + if (_.isEqual(o, this[i])) { + return i; + } + } + return -1; + } +}/** + * 特殊情况 + * Created by wang on 15/6/23. + */ +//解决console未定义问题 guy +window.console = window.console || (function () { + var c = {}; + c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile + = c.clear = c.exception = c.trace = c.assert = function () { + }; + return c; + })(); +/* + * 前端缓存 + */ +window.localStorage || (window.localStorage = { + items: {}, + setItem: function (k, v) { + BI.Cache.addCookie(k, v); + }, + getItem: function (k) { + return BI.Cache.getCookie(k); + }, + removeItem: function (k) { + BI.Cache.deleteCookie(k); + }, + key: function () { + + }, + clear: function () { + this.items = {}; + } +});//修复ie9下sort方法的bug +!function (window) { + var ua = window.navigator.userAgent.toLowerCase(), + reg = /msie|applewebkit.+safari/; + if (reg.test(ua)) { + var _sort = Array.prototype.sort; + Array.prototype.sort = function (fn) { + if (!!fn && typeof fn === 'function') { + if (this.length < 2) { + return this; + } + var i = 0, j = i + 1, l = this.length, tmp, r = false, t = 0; + for (; i < l; i++) { + for (j = i + 1; j < l; j++) { + t = fn.call(this, this[i], this[j]); + r = (typeof t === 'number' ? t : + !!t ? 1 : 0) > 0; + if (r === true) { + tmp = this[i]; + this[i] = this[j]; + this[j] = tmp; + } + } + } + return this; + } else { + return _sort.call(this); + } + }; + } }(window); \ No newline at end of file diff --git a/docs/widget.css b/docs/widget.css index 0d58f4cd4..d07adc5bf 100644 --- a/docs/widget.css +++ b/docs/widget.css @@ -1,416 +1,416 @@ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-arrangement .arrangement-helper { - background: #3f8ce8; - z-index: 1000000000; -} -.bi-arrangement .arrangement-block { - z-index: 1000000000; -} -.bi-arrangement .arrangement-drop-container { - z-index: 1000000000; -} -.bi-arrangement .arrangement-drop-container .arrangement-drop-region { - overflow: hidden; -} -.bi-arrangement .arrangement-drop-container .drop-devider { - z-index: 1000000001; - background: #3f8ce8; -} -.bi-arrangement .arrangement-drop-container .top-left, -.bi-arrangement .arrangement-drop-container .top-right, -.bi-arrangement .arrangement-drop-container .bottom-left, -.bi-arrangement .arrangement-drop-container .bottom-right, -.bi-arrangement .arrangement-drop-container .top-left-second, -.bi-arrangement .arrangement-drop-container .top-right-second, -.bi-arrangement .arrangement-drop-container .bottom-left-second, -.bi-arrangement .arrangement-drop-container .bottom-right-second, -.bi-arrangement .arrangement-drop-container .top-center, -.bi-arrangement .arrangement-drop-container .bottom-center, -.bi-arrangement .arrangement-drop-container .left-center, -.bi-arrangement .arrangement-drop-container .right-center, -.bi-arrangement .arrangement-drop-container .top-center-second, -.bi-arrangement .arrangement-drop-container .bottom-center-second, -.bi-arrangement .arrangement-drop-container .left-center-second, -.bi-arrangement .arrangement-drop-container .right-center-second { - z-index: 1000000001; - background: #3f8ce8; -} -.bi-arrangement-droppable { - z-index: 100000; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-adapt-editor .adapt-editor-text { - font-size: 14px; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -/*************BI.SearchEditor******************/ -.bi-search-editor { - border: 1px solid #d4dadd; -} -.bi-search-editor .close-font { - font-size: 20px; -} -.bi-search-editor .search-font { - font-size: 20px; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -/*************BI.SearchEditor******************/ -.bi-small-search-editor .bi-editor { - font-size: 12px; -} -.bi-small-search-editor .bi-editor .bi-input { - font-size: 12px; -} -.bi-small-search-editor .bi-editor .bi-label { - font-size: 12px; -} -.bi-small-search-editor .close-font { - font-size: 18px; -} -.bi-small-search-editor .search-font { - font-size: 18px; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-sign-initial-editor .sign-initial-editor-text { - font-size: 14px; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-sign-style-editor .sign-style-editor-text { - max-width: 100%; - font-size: 12px; -} -.bi-sign-style-editor .sign-style-editor-tip { - max-width: 100%; - font-size: 12px; - color: #808080; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-text-editor { - border: 1px solid #d4dadd; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -/*************BI.SearchEditor******************/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-date-trigger { - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - border-radius: 2px; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-down-list-popup .bi-down-list-item .list-item-text { - max-width: 203px; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-excel-table > div.bottom-right > div > div > table { - border-right: 1px solid #d4dadd; -} -.bi-theme-dark .bi-excel-table > div.bottom-right > div > div > table { - border-right: 1px solid #525466; -} -.bi-excel-table-header-cell { - font-weight: bold; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-file-manager-nav-button .file-manager-nav-button-text { - max-width: 200px; -} -.bi-file-manager-nav-button .file-manager-nav-button-text.active { - background-color: #eff1f4; - color: #999999; -} -.bi-file-manager-nav-button .file-manager-nav-button-triangle { - z-index: 1; -} -.bi-theme-dark .bi-file-manager-nav-button .file-manager-nav-button-text.active { - background-color: #191b2b; - color: #999999; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-fine-tuning-number-editor { - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - border-radius: 2px; -} -.bi-interactive-arrangement .interactive-arrangement-dragtag-line { - z-index: 1000000000; - background-color: #f07d0a; -} -.bi-interactive-arrangement .interactive-arrangement-dragtag-icon { - z-index: 1000000000; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-month-trigger { - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - border-radius: 2px; -} -.bi-multi-select-check-pane .multi-select-check-selected { - text-decoration: underline; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-multi-select-combo .multi-select-trigger-icon-button { - font-size: 16px; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-multi-select-trigger { - -webkit-border-radius: 2px 2px 2px 2px; - -moz-border-radius: 2px 2px 2px 2px; - border-radius: 2px 2px 2px 2px; -} -.bi-multi-select-search-pane .multi-select-toolbar { - color: #e85050; -} -.bi-multi-select-check-selected-button { - z-index: 1; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-multi-tree-check-pane .multi-tree-check-selected { - color: #3f8ce8; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-multi-tree-combo .multi-select-trigger-icon-button { - font-size: 16px; -} -.bi-multi-tree-popup .popup-view-tree { - min-height: 170px; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-multi-tree-check-selected-button .trigger-check-selected { - color: #3f8ce8; - z-index: 1; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-numerical-interval .numerical-interval-small-editor { - -moz-border-radius-topleft: 2px; - -webkit-border-top-left-radius: 2px; - -moz-border-radius-bottomleft: 2px; - -webkit-border-bottom-left-radius: 2px; - border-top-left-radius: 2px; - border-bottom-left-radius: 2px; -} -.bi-numerical-interval .numerical-interval-big-editor { - -moz-border-radius-topright: 2px; - -webkit-border-top-right-radius: 2px; - -moz-border-radius-bottomright: 2px; - -webkit-border-bottom-right-radius: 2px; - border-top-right-radius: 2px; - border-bottom-right-radius: 2px; -} -.bi-numerical-interval .numerical-interval-big-combo { - -moz-border-radius-topleft: 2px; - -webkit-border-top-left-radius: 2px; - -moz-border-radius-bottomleft: 2px; - -webkit-border-bottom-left-radius: 2px; - border-top-left-radius: 2px; - border-bottom-left-radius: 2px; -} -.bi-numerical-interval .numerical-interval-big-combo .bi-icon-combo-trigger .icon-combo-trigger-icon { - font-size: 14px; -} -.bi-numerical-interval .numerical-interval-small-combo { - -moz-border-radius-topright: 2px; - -webkit-border-top-right-radius: 2px; - -moz-border-radius-bottomright: 2px; - -webkit-border-bottom-right-radius: 2px; - border-top-right-radius: 2px; - border-bottom-right-radius: 2px; -} -.bi-numerical-interval .numerical-interval-small-combo .bi-icon-combo-trigger .icon-combo-trigger-icon { - font-size: 14px; -} -.bi-numerical-interval.number-error .bi-input { - color: #e85050; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-page-table-cell { - -webkit-user-select: initial; - -khtml-user-select: initial; - -moz-user-select: initial; - -ms-user-select: initial; - -o-user-select: initial; - user-select: initial; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-path-chooser .path-chooser-radio { - z-index: 1; -} -.bi-path-region .path-region-label { - z-index: 1; -} -.bi-preview-table-cell { - min-height: 25px; - min-width: 80px; - max-width: 220px; -} -.bi-preview-table { - -webkit-user-select: initial; - -khtml-user-select: initial; - -moz-user-select: initial; - -ms-user-select: initial; - -o-user-select: initial; - user-select: initial; -} -.bi-preview-table > div > table > thead > tr.odd, -.bi-preview-table > div > div > div > table > thead > tr.odd { - background-color: #eff1f4; -} -.bi-theme-dark .bi-preview-table > div > table > thead > tr.odd, -.bi-theme-dark .bi-preview-table > div > div > div > table > thead > tr.odd { - background-color: #191b2b; -} -.bi-preview-table-header-cell { - font-weight: bold; - min-height: 25px; - min-width: 80px; - max-width: 220px; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-quarter-trigger { - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - border-radius: 2px; -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-relation-view-region .relation-view-region-container { - z-index: 1; - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - border-radius: 2px; -} -.bi-relation-view-region .relation-view-region-container.other-package { - border-style: dashed; -} -.bi-sequence-table-dynamic-number .sequence-table-title-cell { - overflow: hidden; - overflow-x: hidden; - overflow-y: hidden; - -webkit-box-sizing: border-box; - /*Safari3.2+*/ - -moz-box-sizing: border-box; - /*Firefox3.5+*/ - -ms-box-sizing: border-box; - /*IE8*/ - box-sizing: border-box; - /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ -} -.bi-sequence-table-dynamic-number .sequence-table-number-cell { - -webkit-box-sizing: border-box; - /*Safari3.2+*/ - -moz-box-sizing: border-box; - /*Firefox3.5+*/ - -ms-box-sizing: border-box; - /*IE8*/ - box-sizing: border-box; - /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ -} -.bi-sequence-table-list-number .sequence-table-title-cell { - overflow: hidden; - overflow-x: hidden; - overflow-y: hidden; - -webkit-box-sizing: border-box; - /*Safari3.2+*/ - -moz-box-sizing: border-box; - /*Firefox3.5+*/ - -ms-box-sizing: border-box; - /*IE8*/ - box-sizing: border-box; - /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ -} -.bi-sequence-table-list-number .sequence-table-number-cell { - -webkit-box-sizing: border-box; - /*Safari3.2+*/ - -moz-box-sizing: border-box; - /*Firefox3.5+*/ - -ms-box-sizing: border-box; - /*IE8*/ - box-sizing: border-box; - /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-sequence-table-tree-number .sequence-table-title-cell { - overflow: hidden; - overflow-x: hidden; - overflow-y: hidden; - -webkit-box-sizing: border-box; - /*Safari3.2+*/ - -moz-box-sizing: border-box; - /*Firefox3.5+*/ - -ms-box-sizing: border-box; - /*IE8*/ - box-sizing: border-box; - /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ -} -.bi-sequence-table-tree-number .sequence-table-number-cell { - -webkit-box-sizing: border-box; - /*Safari3.2+*/ - -moz-box-sizing: border-box; - /*Firefox3.5+*/ - -ms-box-sizing: border-box; - /*IE8*/ - box-sizing: border-box; - /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ -} -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-year-popup .year-popup-navigation { - line-height: 30px; -} -.bi-year-popup .year-popup-navigation > .center-element { - border-left: 1px solid #d4dadd; -} -.bi-year-popup .year-popup-navigation > .first-element { - border-left: none; -} -.bi-theme-dark .bi-year-popup .year-popup-navigation > .center-element { - border-left: 1px solid #525466; -} -.bi-theme-dark .bi-year-popup .year-popup-navigation > .first-element { - border-left: none; -} -.bi-year-trigger { - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - border-radius: 2px; -} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-arrangement .arrangement-helper { + background: #3f8ce8; + z-index: 1000000000; +} +.bi-arrangement .arrangement-block { + z-index: 1000000000; +} +.bi-arrangement .arrangement-drop-container { + z-index: 1000000000; +} +.bi-arrangement .arrangement-drop-container .arrangement-drop-region { + overflow: hidden; +} +.bi-arrangement .arrangement-drop-container .drop-devider { + z-index: 1000000001; + background: #3f8ce8; +} +.bi-arrangement .arrangement-drop-container .top-left, +.bi-arrangement .arrangement-drop-container .top-right, +.bi-arrangement .arrangement-drop-container .bottom-left, +.bi-arrangement .arrangement-drop-container .bottom-right, +.bi-arrangement .arrangement-drop-container .top-left-second, +.bi-arrangement .arrangement-drop-container .top-right-second, +.bi-arrangement .arrangement-drop-container .bottom-left-second, +.bi-arrangement .arrangement-drop-container .bottom-right-second, +.bi-arrangement .arrangement-drop-container .top-center, +.bi-arrangement .arrangement-drop-container .bottom-center, +.bi-arrangement .arrangement-drop-container .left-center, +.bi-arrangement .arrangement-drop-container .right-center, +.bi-arrangement .arrangement-drop-container .top-center-second, +.bi-arrangement .arrangement-drop-container .bottom-center-second, +.bi-arrangement .arrangement-drop-container .left-center-second, +.bi-arrangement .arrangement-drop-container .right-center-second { + z-index: 1000000001; + background: #3f8ce8; +} +.bi-arrangement-droppable { + z-index: 100000; +} +/****添加计算宽度的--运算符直接需要space****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-adapt-editor .adapt-editor-text { + font-size: 14px; +} +/****添加计算宽度的--运算符直接需要space****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +/*************BI.SearchEditor******************/ +.bi-search-editor { + border: 1px solid #d4dadd; +} +.bi-search-editor .close-font { + font-size: 20px; +} +.bi-search-editor .search-font { + font-size: 20px; +} +/****添加计算宽度的--运算符直接需要space****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +/*************BI.SearchEditor******************/ +.bi-small-search-editor .bi-editor { + font-size: 12px; +} +.bi-small-search-editor .bi-editor .bi-input { + font-size: 12px; +} +.bi-small-search-editor .bi-editor .bi-label { + font-size: 12px; +} +.bi-small-search-editor .close-font { + font-size: 18px; +} +.bi-small-search-editor .search-font { + font-size: 18px; +} +/****添加计算宽度的--运算符直接需要space****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-sign-initial-editor .sign-initial-editor-text { + font-size: 14px; +} +/****添加计算宽度的--运算符直接需要space****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-sign-style-editor .sign-style-editor-text { + max-width: 100%; + font-size: 12px; +} +.bi-sign-style-editor .sign-style-editor-tip { + max-width: 100%; + font-size: 12px; + color: #808080; +} +/****添加计算宽度的--运算符直接需要space****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-text-editor { + border: 1px solid #d4dadd; +} +/****添加计算宽度的--运算符直接需要space****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +/*************BI.SearchEditor******************/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-date-trigger { + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-down-list-popup .bi-down-list-item .list-item-text { + max-width: 203px; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-excel-table > div.bottom-right > div > div > table { + border-right: 1px solid #d4dadd; +} +.bi-theme-dark .bi-excel-table > div.bottom-right > div > div > table { + border-right: 1px solid #525466; +} +.bi-excel-table-header-cell { + font-weight: bold; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-file-manager-nav-button .file-manager-nav-button-text { + max-width: 200px; +} +.bi-file-manager-nav-button .file-manager-nav-button-text.active { + background-color: #eff1f4; + color: #999999; +} +.bi-file-manager-nav-button .file-manager-nav-button-triangle { + z-index: 1; +} +.bi-theme-dark .bi-file-manager-nav-button .file-manager-nav-button-text.active { + background-color: #191b2b; + color: #999999; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-fine-tuning-number-editor { + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} +.bi-interactive-arrangement .interactive-arrangement-dragtag-line { + z-index: 1000000000; + background-color: #f07d0a; +} +.bi-interactive-arrangement .interactive-arrangement-dragtag-icon { + z-index: 1000000000; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-month-trigger { + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} +.bi-multi-select-check-pane .multi-select-check-selected { + text-decoration: underline; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-multi-select-combo .multi-select-trigger-icon-button { + font-size: 16px; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-multi-select-trigger { + -webkit-border-radius: 2px 2px 2px 2px; + -moz-border-radius: 2px 2px 2px 2px; + border-radius: 2px 2px 2px 2px; +} +.bi-multi-select-search-pane .multi-select-toolbar { + color: #e85050; +} +.bi-multi-select-check-selected-button { + z-index: 1; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-multi-tree-check-pane .multi-tree-check-selected { + color: #3f8ce8; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-multi-tree-combo .multi-select-trigger-icon-button { + font-size: 16px; +} +.bi-multi-tree-popup .popup-view-tree { + min-height: 170px; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-multi-tree-check-selected-button .trigger-check-selected { + color: #3f8ce8; + z-index: 1; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-numerical-interval .numerical-interval-small-editor { + -moz-border-radius-topleft: 2px; + -webkit-border-top-left-radius: 2px; + -moz-border-radius-bottomleft: 2px; + -webkit-border-bottom-left-radius: 2px; + border-top-left-radius: 2px; + border-bottom-left-radius: 2px; +} +.bi-numerical-interval .numerical-interval-big-editor { + -moz-border-radius-topright: 2px; + -webkit-border-top-right-radius: 2px; + -moz-border-radius-bottomright: 2px; + -webkit-border-bottom-right-radius: 2px; + border-top-right-radius: 2px; + border-bottom-right-radius: 2px; +} +.bi-numerical-interval .numerical-interval-big-combo { + -moz-border-radius-topleft: 2px; + -webkit-border-top-left-radius: 2px; + -moz-border-radius-bottomleft: 2px; + -webkit-border-bottom-left-radius: 2px; + border-top-left-radius: 2px; + border-bottom-left-radius: 2px; +} +.bi-numerical-interval .numerical-interval-big-combo .bi-icon-combo-trigger .icon-combo-trigger-icon { + font-size: 14px; +} +.bi-numerical-interval .numerical-interval-small-combo { + -moz-border-radius-topright: 2px; + -webkit-border-top-right-radius: 2px; + -moz-border-radius-bottomright: 2px; + -webkit-border-bottom-right-radius: 2px; + border-top-right-radius: 2px; + border-bottom-right-radius: 2px; +} +.bi-numerical-interval .numerical-interval-small-combo .bi-icon-combo-trigger .icon-combo-trigger-icon { + font-size: 14px; +} +.bi-numerical-interval.number-error .bi-input { + color: #e85050; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-page-table-cell { + -webkit-user-select: initial; + -khtml-user-select: initial; + -moz-user-select: initial; + -ms-user-select: initial; + -o-user-select: initial; + user-select: initial; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-path-chooser .path-chooser-radio { + z-index: 1; +} +.bi-path-region .path-region-label { + z-index: 1; +} +.bi-preview-table-cell { + min-height: 25px; + min-width: 80px; + max-width: 220px; +} +.bi-preview-table { + -webkit-user-select: initial; + -khtml-user-select: initial; + -moz-user-select: initial; + -ms-user-select: initial; + -o-user-select: initial; + user-select: initial; +} +.bi-preview-table > div > table > thead > tr.odd, +.bi-preview-table > div > div > div > table > thead > tr.odd { + background-color: #eff1f4; +} +.bi-theme-dark .bi-preview-table > div > table > thead > tr.odd, +.bi-theme-dark .bi-preview-table > div > div > div > table > thead > tr.odd { + background-color: #191b2b; +} +.bi-preview-table-header-cell { + font-weight: bold; + min-height: 25px; + min-width: 80px; + max-width: 220px; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-quarter-trigger { + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-relation-view-region .relation-view-region-container { + z-index: 1; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} +.bi-relation-view-region .relation-view-region-container.other-package { + border-style: dashed; +} +.bi-sequence-table-dynamic-number .sequence-table-title-cell { + overflow: hidden; + overflow-x: hidden; + overflow-y: hidden; + -webkit-box-sizing: border-box; + /*Safari3.2+*/ + -moz-box-sizing: border-box; + /*Firefox3.5+*/ + -ms-box-sizing: border-box; + /*IE8*/ + box-sizing: border-box; + /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ +} +.bi-sequence-table-dynamic-number .sequence-table-number-cell { + -webkit-box-sizing: border-box; + /*Safari3.2+*/ + -moz-box-sizing: border-box; + /*Firefox3.5+*/ + -ms-box-sizing: border-box; + /*IE8*/ + box-sizing: border-box; + /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ +} +.bi-sequence-table-list-number .sequence-table-title-cell { + overflow: hidden; + overflow-x: hidden; + overflow-y: hidden; + -webkit-box-sizing: border-box; + /*Safari3.2+*/ + -moz-box-sizing: border-box; + /*Firefox3.5+*/ + -ms-box-sizing: border-box; + /*IE8*/ + box-sizing: border-box; + /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ +} +.bi-sequence-table-list-number .sequence-table-number-cell { + -webkit-box-sizing: border-box; + /*Safari3.2+*/ + -moz-box-sizing: border-box; + /*Firefox3.5+*/ + -ms-box-sizing: border-box; + /*IE8*/ + box-sizing: border-box; + /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-sequence-table-tree-number .sequence-table-title-cell { + overflow: hidden; + overflow-x: hidden; + overflow-y: hidden; + -webkit-box-sizing: border-box; + /*Safari3.2+*/ + -moz-box-sizing: border-box; + /*Firefox3.5+*/ + -ms-box-sizing: border-box; + /*IE8*/ + box-sizing: border-box; + /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ +} +.bi-sequence-table-tree-number .sequence-table-number-cell { + -webkit-box-sizing: border-box; + /*Safari3.2+*/ + -moz-box-sizing: border-box; + /*Firefox3.5+*/ + -ms-box-sizing: border-box; + /*IE8*/ + box-sizing: border-box; + /*W3C标准(IE9+,Safari5.1+,Chrome10.0+,Opera10.6+都符合box-sizing的w3c标准语法)*/ +} +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +/****** common color(常用颜色,可用于普遍场景) *****/ +/**** custom color(自定义颜色,用于特定场景) ****/ +.bi-year-popup .year-popup-navigation { + line-height: 30px; +} +.bi-year-popup .year-popup-navigation > .center-element { + border-left: 1px solid #d4dadd; +} +.bi-year-popup .year-popup-navigation > .first-element { + border-left: none; +} +.bi-theme-dark .bi-year-popup .year-popup-navigation > .center-element { + border-left: 1px solid #525466; +} +.bi-theme-dark .bi-year-popup .year-popup-navigation > .first-element { + border-left: none; +} +.bi-year-trigger { + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} diff --git a/docs/widget.js b/docs/widget.js index 6ada13256..8d7b66d04 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -1,3 +1,4 @@ +<<<<<<< HEAD /** * * Created by GUY on 2016/5/26. @@ -16638,4 +16639,16152 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, { } }); BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; +======= +/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableTreeNumber + * @extends BI.Widget + */ +BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-tree-number", + isNeedFreeze: false, + startSequence: 1,//开始的序号 + scrollTop: 0, + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: null, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.vCurr = 1; + this.hCurr = 1; + this.tasks = []; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: this._getHeaderHeight() - 2 + }, {el: {type: "bi.layout"}, height: 2}, { + el: this.scrollContainer + }] + }); + //缓存第一行对应的序号 + this.start = this.options.startSequence; + this.cache = {}; + this._nextState(); + + this._populate(); + }, + + _getNextSequence: function (nodes) { + var self = this; + var start = this.start; + var cnt = this.start; + + function track(node) { + //如果已经有缓存了就不改计数了,复杂表会出现这种情况 + self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt); + cnt++; + } + + BI.each(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = cnt = self.cache[child.text || child.value]; + } + } + track(child) + }); + } + }); + this.start = cnt; + return start; + }, + + _getStart: function (nodes) { + var self = this; + var start = this.start; + BI.some(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = self.cache[child.text || child.value]; + return true; + } + } + }); + } + }); + return start; + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount(node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = this._getHeaderHeight() - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _getHeaderHeight: function () { + var o = this.options; + return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0)); + }, + + _nextState: function () { + var o = this.options; + this._getNextSequence(o.items); + }, + + _prevState: function () { + var self = this, o = this.options; + var firstChild; + BI.some(o.items, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (j, child) { + firstChild = child; + return true; + }); + } + }); + if (firstChild && BI.isNotEmptyObject(this.cache)) { + this.start = this.cache[firstChild.text || firstChild.value]; + } else { + this.start = 1; + } + this._nextState(); + }, + + _getMaxScrollTop: function (numbers) { + var cnt = 0; + BI.each(numbers, function (i, number) { + cnt += number.cnt; + }); + return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth()); + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + + var renderedCells = [], renderedKeys = []; + var numbers = this._formatNumber(o.items); + var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0); + BI.each(numbers, function (i, number) { + intervalTree.set(i, number.height); + }); + var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers)); + var index = intervalTree.greatestLowerBound(scrollTop); + var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0)); + var height = offsetTop; + var bodyHeight = o.height - this._getHeaderHeight(); + while (height < bodyHeight && index < numbers.length) { + renderedKeys.push(index); + offsetTop += numbers[index].height; + height += numbers[index].height; + index++; + } + + BI.each(renderedKeys, function (i, key) { + var index = BI.deepIndexOf(self.renderedKeys, key); + if (index > -1) { + if (numbers[key].height !== self.renderedCells[index]._height) { + self.renderedCells[index]._height = numbers[key].height; + self.renderedCells[index].el.setHeight(numbers[key].height); + } + if (numbers[key].top !== self.renderedCells[index].top) { + self.renderedCells[index].top = numbers[key].top; + self.renderedCells[index].el.element.css("top", numbers[key].top + "px"); + } + renderedCells.push(self.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + styleGetter: numbers[key].isSummary === true ? function () { + return o.summaryCellStyleGetter(true); + } : function (key) { + return function () { + return o.sequenceCellStyleGetter(key); + } + }(numbers[key].index) + }, numbers[key])); + renderedCells.push({ + el: child, + left: 0, + top: numbers[key].top, + _height: numbers[key].height + }); + } + }); + + //已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]) + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + + this.container.setHeight(intervalTree.sumUntil(numbers.length)); + }, + + _restore: function () { + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + _populate: function () { + var self = this; + BI.each(this.tasks, function (i, task) { + task.apply(self); + }); + this.tasks = []; + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + if (v <= 1) { + this.cache = {}; + this.start = this.options.startSequence; + this._restore(); + this.tasks.push(this._nextState); + } else if (v === this.vCurr + 1) { + this.tasks.push(this._nextState); + } else if (v === this.vCurr - 1) { + this.tasks.push(this._prevState); + } + this.vCurr = v; + }, + + setHPage: function (v) { + if (v !== this.hCurr) { + this.tasks.push(this._prevState); + } + this.hCurr = v; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + this.tasks.push(this._prevState); + } + if (header && header !== this.options.header) { + o.header = header; + } + if (crossItems && crossItems !== this.options.crossItems) { + o.crossItems = crossItems; + } + if (crossHeader && crossHeader !== this.options.crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + } +}); +BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/** + * 自适应布局 + * + * 1、resize + * 2、吸附 + * 3、当前组件在最上方 + * 4、可以撤销 + * 5、上下之间插入组件 + * + * Created by GUY on 2016/2/23. + * @class BI.AdaptiveArrangement + * @extends BI.Widget + */ +BI.AdaptiveArrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-adaptive-arrangement", + resizable: true, + layoutType: BI.Arrangement.LAYOUT_TYPE.FREE, + items: [] + }); + }, + + _init: function () { + BI.AdaptiveArrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.arrangement", + element: this, + layoutType: o.layoutType, + items: o.items + }); + this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () { + self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments); + }); + this.zIndex = 0; + BI.each(o.items, function (i, item) { + self._initResizable(item.el); + }); + + $(document).mousedown(function (e) { + BI.each(self.getAllRegions(), function (i, region) { + if (region.el.element.find(e.target).length === 0) { + region.el.element.removeClass("selected"); + } + }); + }); + BI.ResizeDetector.addResizeListener(this, function () { + self.arrangement.resize(); + self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); + }); + }, + + _isEqual: function () { + return this.arrangement._isEqual.apply(this.arrangement, arguments); + }, + + _setSelect: function (item) { + if (!item.element.hasClass("selected")) { + item.element.css("zIndex", ++this.zIndex); + BI.each(this.getAllRegions(), function (i, region) { + region.el.element.removeClass("selected"); + }); + item.element.addClass("selected"); + } + }, + + _initResizable: function (item) { + var self = this, o = this.options; + item.element.css("zIndex", ++this.zIndex); + item.element.mousedown(function () { + self._setSelect(item) + }); + // o.resizable && item.element.resizable({ + // handles: "e, s, se", + // minWidth: 20, + // minHeight: 20, + // autoHide: true, + // helper: "bi-resizer", + // start: function () { + // item.element.css("zIndex", ++self.zIndex); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE); + // }, + // resize: function (e, ui) { + // // self._resize(item.attr("id"), ui.size); + // self._resize(item.attr("id"), e, ui.size, ui.position); + // }, + // stop: function (e, ui) { + // self._stopResize(item.attr("id"), ui.size); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); + // } + // }); + }, + + // _resize: function (name, e, size, position) { + // var self = this; + // this.scrollInterval(e, false, true, function (changedSize) { + // size.width += changedSize.offsetX; + // size.height += changedSize.offsetY; + // var containerWidth = self.arrangement.container.element.width(); + // var containerHeight = self.arrangement.container.element.height(); + // self.arrangement.container.element.width(containerWidth + changedSize.offsetX); + // self.arrangement.container.element.height(containerHeight + changedSize.offsetY); + // switch (self.getLayoutType()) { + // case BI.Arrangement.LAYOUT_TYPE.FREE: + // break; + // case BI.Arrangement.LAYOUT_TYPE.GRID: + // self.setRegionSize(name, size); + // break; + // } + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size); + // }); + // }, + // + // _stopResize: function (name, size) { + // var self = this; + // this.scrollEnd(); + // switch (this.getLayoutType()) { + // case BI.Arrangement.LAYOUT_TYPE.FREE: + // this.setRegionSize(name, size); + // break; + // case BI.Arrangement.LAYOUT_TYPE.GRID: + // this.setRegionSize(name, size); + // break; + // } + // }, + + _getScrollOffset: function () { + return this.arrangement._getScrollOffset(); + }, + + getClientWidth: function () { + return this.arrangement.getClientWidth(); + }, + + getClientHeight: function () { + return this.arrangement.getClientHeight(); + }, + + addRegion: function (region, position) { + this._initResizable(region.el); + this._setSelect(region.el); + var self = this, flag; + var old = this.arrangement.getAllRegions(); + if (flag = this.arrangement.addRegion(region, position)) { + this._old = old; + } + return flag; + }, + + deleteRegion: function (name) { + var flag; + var old = this.getAllRegions(); + if (flag = this.arrangement.deleteRegion(name)) { + this._old = old; + } else { + this._old = this.getAllRegions(); + this.relayout(); + } + return flag; + }, + + setRegionSize: function (name, size) { + var flag; + var old = this.getAllRegions(); + if (flag = this.arrangement.setRegionSize(name, size)) { + this._old = old; + } + return flag; + }, + + setPosition: function (position, size) { + var self = this; + return this.arrangement.setPosition(position, size); + }, + + setRegionPosition: function (name, position) { + var region = this.getRegionByName(name); + return this.arrangement.setRegionPosition(name, position); + }, + + setDropPosition: function (position, size) { + return this.arrangement.setDropPosition(position, size); + }, + + scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { + var self = this; + var map = { + top: [-1, 0], + bottom: [1, 0], + left: [0, -1], + right: [0, 1] + }; + var clientSize = this.element.bounds(); + + function scrollTo(direction, callback) { + if (direction === "") { + self.lastActiveRegion = ""; + if (self._scrollInterval) { + clearInterval(self._scrollInterval); + self._scrollInterval = null; + } + return; + } + if (self.lastActiveRegion !== direction) { + self.lastActiveRegion = direction; + if (self._scrollInterval) { + clearInterval(self._scrollInterval); + self._scrollInterval = null; + } + self._scrollInterval = setInterval(function () { + var offset = self._getScrollOffset(); + var t = offset.top + map[direction][0] * 40; + var l = offset.left + map[direction][1] * 40; + if (t < 0 || l < 0) { + return; + } + callback({ + offsetX: map[direction][1] * 40, + offsetY: map[direction][0] * 40 + }); + self.scrollTo({ + top: t, + left: l + }); + }, 300); + } + } + + cb({ + offsetX: 0, + offsetY: 0 + }); + var offset = this.element.offset(); + var p = { + left: e.pageX - offset.left, + top: e.pageY - offset.top + }; + //向上滚 + if (isBorderScroll && p.top >= 0 && p.top <= 30) { + scrollTo("top", cb) + } + //向下滚 + else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) { + scrollTo("bottom", cb) + } + //向左滚 + else if (isBorderScroll && p.left >= 0 && p.left <= 30) { + scrollTo("left", cb) + } + //向右滚 + else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) { + scrollTo("right", cb) + } else { + if (isOverflowScroll === true) { + if (p.top < 0) { + scrollTo("top", cb); + } + else if (p.top > clientSize.height) { + scrollTo("bottom", cb); + } + else if (p.left < 0) { + scrollTo("left", cb); + } + else if (p.left > clientSize.width) { + scrollTo("right", cb); + } else { + scrollTo("", cb); + } + } else { + scrollTo("", cb); + } + } + }, + + scrollEnd: function () { + this.lastActiveRegion = ""; + if (this._scrollInterval) { + clearInterval(this._scrollInterval); + this._scrollInterval = null; + } + }, + + scrollTo: function (scroll) { + this.arrangement.scrollTo(scroll); + }, + + zoom: function (ratio) { + this.arrangement.zoom(ratio); + }, + + resize: function () { + this.arrangement.resize(); + }, + + relayout: function () { + return this.arrangement.relayout(); + }, + + setLayoutType: function (type) { + var self = this; + this.arrangement.setLayoutType(type); + }, + + getLayoutType: function () { + return this.arrangement.getLayoutType(); + }, + + getLayoutRatio: function () { + return this.arrangement.getLayoutRatio(); + }, + + getHelper: function () { + return this.arrangement.getHelper(); + }, + + getRegionByName: function (name) { + return this.arrangement.getRegionByName(name); + }, + + getAllRegions: function () { + return this.arrangement.getAllRegions(); + }, + + revoke: function () { + if (this._old) { + this.populate(BI.toArray(this._old)); + } + }, + + populate: function (items) { + var self = this; + BI.each(items, function (i, item) { + self._initResizable(item.el); + }); + this.arrangement.populate(items); + } +}); +BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE"; +BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE"; +BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE"; +BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE"; +BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL"; +BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/** + * Arrangement的block面板 + * + * Created by GUY on 2016/3/1. + * @class BI.ArrangementBlock + * @extends BI.Widget + */ +BI.ArrangementBlock = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement-block bi-mask" + }); + } +}); +BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/** + * Arrangement的drop面板 + * + * Created by GUY on 2016/3/1. + * @class BI.ArrangementDroppable + * @extends BI.Widget + */ +BI.ArrangementDroppable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement-droppable bi-resizer" + }); + } +}); +BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/** + * 布局 + * + * Created by GUY on 2016/2/23. + * @class BI.Arrangement + * @extends BI.Widget + */ +BI.Arrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement", + layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, + items: [] + }); + }, + + _init: function () { + BI.Arrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.arrangement_droppable", + cls: "arrangement-block", + invisible: true + }); + this.block = BI.createWidget({ + type: "bi.arrangement_block", + invisible: true + }); + this.container = BI.createWidget({ + type: "bi.absolute", + items: o.items.concat([this.block, this.arrangement]) + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.adaptive", + width: "100%", + height: "100%", + scrollable: true, + items: [this.container] + }); + this.scrollContainer.element.scroll(function () { + self.fireEvent(BI.Arrangement.EVENT_SCROLL, { + scrollLeft: self.scrollContainer.element.scrollLeft(), + scrollTop: self.scrollContainer.element.scrollTop(), + clientWidth: self.scrollContainer.element[0].clientWidth, + clientHeight: self.scrollContainer.element[0].clientHeight + }); + }); + + BI.createWidget({ + type: "bi.adaptive", + element: this, + items: [this.scrollContainer] + }); + this.regions = {}; + if (o.items.length > 0) { + BI.nextTick(function () { + self.populate(o.items); + }); + } + }, + + ////初始化操作//// + _calculateRegions: function (items) { + var self = this, o = this.options; + this.regions = {}; + BI.each(items, function (i, item) { + var region = self._createOneRegion(item); + self.regions[region.id] = region; + }); + }, + + _isEqual: function (num1, num2) { + return Math.abs(num1 - num2) < 2; + }, + + _isLessThan: function (num1, num2) { + return num1 < num2 && !this._isEqual(num1, num2); + }, + + _isMoreThan: function (num1, num2) { + return num1 > num2 && !this._isEqual(num1, num2); + }, + + _isLessThanEqual: function (num1, num2) { + return num1 <= num2 || this._isEqual(num1, num2); + }, + + _isMoreThanEqual: function (num1, num2) { + return num1 >= num2 || this._isEqual(num1, num2); + }, + + //获取占有的最大Region + _getRegionOccupied: function (regions) { + var self = this, o = this.options; + if (BI.size(regions || this.regions) <= 0) { + return { + left: 0, + top: 0, + width: 0, + height: 0 + } + } + var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN; + BI.each(regions || this.regions, function (id, region) { + minLeft = Math.min(minLeft, region.left); + maxLeft = Math.max(maxLeft, region.left + region.width); + minTop = Math.min(minTop, region.top); + maxTop = Math.max(maxTop, region.top + region.height); + }); + return { + left: minLeft, + top: minTop, + width: maxLeft - minLeft, + height: maxTop - minTop + } + }, + + //两个区域的交叉面积 + _getCrossArea: function (region1, region2) { + if (region1.left <= region2.left) { + if (region1.top <= region2.top) { + if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) { + if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) { + return 0; + } + return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left); + } + } else { + if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) { + if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) { + return 0; + } + return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left); + } + } + } else { + if (region1.top <= region2.top) { + if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) { + if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) { + return 0; + } + return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left); + } + } else { + if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) { + if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) { + return 0; + } + return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left); + } + } + } + return 0; + }, + + //是否有覆盖的组件 + _isRegionOverlay: function (regions) { + var reg = []; + BI.each(regions || this.regions, function (id, region) { + reg.push(new BI.Region(region.left, region.top, region.width, region.height)); + }); + for (var i = 0, len = reg.length; i < len; i++) { + for (var j = i + 1; j < len; j++) { + var area1 = { + left: reg[i].x, + top: reg[i].y, + width: reg[i].w, + height: reg[i].h + }; + var area2 = { + left: reg[j].x, + top: reg[j].y, + width: reg[j].w, + height: reg[j].h + }; + if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) { + return true; + } + } + } + return false; + }, + + //布局是否是优良的 + _isArrangeFine: function (regions) { + switch (this.options.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + return true; + case BI.Arrangement.LAYOUT_TYPE.GRID: + // if (this._isRegionOverlay()) { + // return false; + // } + } + return true; + }, + + _getRegionNames: function (regions) { + var names = []; + BI.each(regions || this.regions, function (i, region) { + names.push(region.id || region.attr("id")); + }); + return names; + }, + + _getRegionsByNames: function (names, regions) { + names = BI.isArray(names) ? names : [names]; + regions = regions || this.regions; + if (BI.isArray(regions)) { + var result = []; + BI.each(regions, function (i, region) { + if (names.contains(region.id || region.attr("id"))) { + result.push(region); + } + }); + } else { + var result = {}; + BI.each(names, function (i, name) { + result[name] = regions[name]; + }); + } + return result; + }, + + _cloneRegion: function (regions) { + var clone = {}; + BI.each(regions || this.regions, function (id, region) { + clone[id] = {}; + clone[id].el = region.el; + clone[id].id = region.id; + clone[id].left = region.left; + clone[id].top = region.top; + clone[id].width = region.width; + clone[id].height = region.height; + }); + return clone; + }, + + //测试合法性 + _test: function (regions) { + var self = this; + return !BI.any(regions || this.regions, function (i, region) { + if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) { + return true; + } + }) + }, + + _getScrollOffset: function () { + return { + left: this.scrollContainer.element[0].scrollLeft, + top: this.scrollContainer.element[0].scrollTop + } + }, + + ////操作//// + _createOneRegion: function (item) { + var el = BI.createWidget(item.el); + el.setVisible(true); + return { + id: el.attr("id"), + left: item.left, + top: item.top, + width: item.width, + height: item.height, + el: el + } + }, + + _applyRegion: function (regions) { + var self = this, o = this.options; + BI.each(regions || this.regions, function (i, region) { + region.el.element.css({ + left: region.left, + top: region.top, + width: region.width, + height: region.height + }); + }); + this._applyContainer(); + this.ratio = this.getLayoutRatio(); + }, + + _renderRegion: function () { + var self = this; + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: BI.toArray(this.regions) + }); + }, + + getClientWidth: function () { + return this.scrollContainer.element[0].clientWidth; + }, + + getClientHeight: function () { + return this.scrollContainer.element[0].clientHeight; + }, + + _applyContainer: function () { + //先掩藏后显示能够明确滚动条是否出现 + this.scrollContainer.element.css("overflow", "hidden"); + var occupied = this._getRegionOccupied(); + this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height); + this.scrollContainer.element.css("overflow", "auto"); + return occupied; + }, + + _modifyRegion: function (regions) { + BI.each(this.regions, function (id, region) { + if (regions[id]) { + region.left = regions[id].left; + region.top = regions[id].top; + region.width = regions[id].width; + region.height = regions[id].height; + } + }); + }, + + _addRegion: function (item) { + var region = this._createOneRegion(item); + this.regions[region.id] = region; + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [region] + }); + }, + + _deleteRegionByName: function (name) { + this.regions[name].el.setVisible(false); + delete this.regions[name]; + }, + + _setArrangeSize: function (size) { + this.arrangement.element.css({ + left: size.left, + top: size.top, + width: size.width, + height: size.height + }) + }, + + //Grid + _getOneWidthPortion: function () { + return this.getClientWidth() / BI.Arrangement.PORTION; + }, + _getOneHeightPortion: function () { + return this.getClientHeight() / BI.Arrangement.H_PORTION; + }, + + _getGridPositionAndSize: function (position) { + var perWidth = this._getOneWidthPortion(); + var perHeight = this._getOneHeightPortion(); + var widthPortion = Math.round(position.width / perWidth); + var leftPortion = Math.round(position.left / perWidth); + var topPortion = Math.round(position.top / perHeight); + var heightPortion = Math.round(position.height / perHeight); + // if (leftPortion > BI.Arrangement.PORTION) { + // leftPortion = BI.Arrangement.PORTION; + // } + // if (widthPortion > BI.Arrangement.PORTION) { + // widthPortion = BI.Arrangement.PORTION; + // } + // if (leftPortion + widthPortion > BI.Arrangement.PORTION) { + // leftPortion = BI.Arrangement.PORTION - widthPortion; + // } + if (widthPortion === 0) { + widthPortion = 1; + } + if (heightPortion === 0) { + heightPortion = 1; + } + return { + x: leftPortion, + y: topPortion, + w: widthPortion, + h: heightPortion + } + }, + + _getBlockPositionAndSize: function (position) { + var perWidth = this._getOneWidthPortion(); + var perHeight = this._getOneHeightPortion(); + return { + left: position.x * perWidth, + top: position.y * perHeight, + width: position.w * perWidth, + height: position.h * perHeight + }; + }, + + _getLayoutsByRegions: function (regions) { + var self = this; + var result = []; + BI.each(regions || this.regions, function (id, region) { + result.push(BI.extend(self._getGridPositionAndSize(region), { + i: region.id + })) + }); + return result; + }, + + _getLayoutIndexByName: function (layout, name) { + return BI.findIndex(layout, function (i, l) { + return l.i === name; + }); + }, + + _setBlockPositionAndSize: function (size) { + this.block.element.css({ + left: size.left, + top: size.top, + width: size.width, + height: size.height + }); + }, + + _getRegionsByLayout: function (layout) { + var self = this; + var regions = {}; + BI.each(layout, function (i, ly) { + regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), { + id: ly.i + }); + }); + return regions; + }, + + _setRegionsByLayout: function (regions, layout) { + var self = this; + regions || (regions = this.regions); + BI.each(layout, function (i, ly) { + if (regions[ly.i]) { + BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly)); + } + }); + return regions; + }, + + _moveElement: function (layout, l, x, y, isUserAction) { + var self = this; + if (l._static) { + return layout; + } + + if (l.y === y && l.x === x) { + return layout; + } + + var movingUp = y && l.y > y; + if (typeof x === 'number') { + l.x = x; + } + if (typeof y === 'number') { + l.y = y; + } + l.moved = true; + + var sorted = this._sortLayoutItemsByRowCol(layout); + if (movingUp) { + sorted = sorted.reverse(); + } + var collisions = getAllCollisions(sorted, l); + + for (var i = 0, len = collisions.length; i < len; i++) { + var collision = collisions[i]; + if (collision.moved) { + continue; + } + + if (l.y > collision.y && l.y - collision.y > collision.h / 4) { + continue; + } + + if (collision._static) { + layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction); + } else { + layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction); + } + } + + return layout; + + function getAllCollisions(layout, layoutItem) { + return BI.filter(layout, function (i, l) { + return self._collides(l, layoutItem); + }); + } + }, + + _sortLayoutItemsByRowCol: function (layout) { + return [].concat(layout).sort(function (a, b) { + if (a.y > b.y || (a.y === b.y && a.x > b.x)) { + return 1; + } + return -1; + }); + }, + + _collides: function (l1, l2) { + if (l1 === l2) { + return false; + } // same element + if (l1.x + l1.w <= l2.x) { + return false; + } // l1 is left of l2 + if (l1.x >= l2.x + l2.w) { + return false; + } // l1 is right of l2 + if (l1.y + l1.h <= l2.y) { + return false; + } // l1 is above l2 + if (l1.y >= l2.y + l2.h) { + return false; + } // l1 is below l2 + return true; // boxes overlap + }, + + _getFirstCollision: function (layout, layoutItem) { + for (var i = 0, len = layout.length; i < len; i++) { + if (this._collides(layout[i], layoutItem)) { + return layout[i]; + } + } + }, + + _moveElementAwayFromCollision: function (layout, collidesWith, + itemToMove, isUserAction) { + if (isUserAction) { + var fakeItem = { + x: itemToMove.x, + y: itemToMove.y, + w: itemToMove.w, + h: itemToMove.h, + i: '-1' + }; + fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0); + if (!this._getFirstCollision(layout, fakeItem)) { + return this._moveElement(layout, itemToMove, undefined, fakeItem.y); + } + } + + return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1); + }, + + _compactItem: function (compareWith, l, verticalCompact) { + if (verticalCompact) { + while (l.y > 0 && !this._getFirstCollision(compareWith, l)) { + l.y--; + } + } + + var collides; + while ((collides = this._getFirstCollision(compareWith, l))) { + l.y = collides.y + collides.h; + } + return l; + }, + + compact: function (layout, verticalCompact) { + var compareWith = getStatics(layout); + var sorted = this._sortLayoutItemsByRowCol(layout); + var out = []; + + for (var i = 0, len = sorted.length; i < len; i++) { + var l = sorted[i]; + + if (!l._static) { + l = this._compactItem(compareWith, l, verticalCompact); + + compareWith.push(l); + } + + out[layout.indexOf(l)] = l; + + l.moved = false; + } + + return out; + function getStatics(layout) { + return BI.filter(layout, function (i, l) { + return l._static; + }); + } + }, + + ////公有方法//// + getRegionByName: function (name) { + var obj = {}; + obj[name] = this.regions[name]; + return this._cloneRegion(obj)[name]; + }, + + getAllRegions: function () { + return BI.toArray(this._cloneRegion()); + }, + + getHelper: function () { + var helper = BI.createWidget({ + type: "bi.layout", + width: 18, + height: 18, + cls: "arrangement-helper bi-border" + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [helper] + }); + return helper; + }, + + _start: function () { + if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) { + this.block.setVisible(true); + } else { + this.arrangement.setVisible(true); + } + }, + + _stop: function () { + this.arrangement.setVisible(false); + this.block.setVisible(false); + }, + + ////公有操作//// + setLayoutType: function (type) { + var self = this, o = this.options; + if (type !== o.layoutType) { + o.layoutType = type; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.relayout(); + break; + } + } + }, + + getLayoutType: function () { + return this.options.layoutType; + }, + + getLayoutRatio: function () { + var occupied = this._getRegionOccupied(); + var width = this.getClientWidth(), height = this.getClientHeight(); + return { + x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")), + y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##")) + } + }, + + addRegion: function (region, position) { + if (position) { + this.setPosition(position, region); + } + var self = this, o = this.options; + if (!this.position) { + return false; + } + var test = this._cloneRegion(); + BI.each(this.position.regions, function (i, region) { + test[region.id].left = region.left; + test[region.id].top = region.top; + test[region.id].width = region.width; + test[region.id].height = region.height; + + }); + var item = BI.extend({}, region, { + left: this.position.insert.left, + top: this.position.insert.top, + width: this.position.insert.width, + height: this.position.insert.height + }); + var added = this._createOneRegion(item); + test[added.id] = added; + if (this._test(test)) { + delete test[added.id]; + this._modifyRegion(test); + this._addRegion(item); + this._populate(this.getAllRegions()); + return true; + } + return false; + }, + + deleteRegion: function (name) { + if (!this.regions[name]) { + return false; + } + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + this._deleteRegionByName(name); + this._populate(this.getAllRegions()); + return true; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this._deleteRegionByName(name); + this._populate(this.getAllRegions()); + this.resize(); + return true; + } + return false; + }, + + setRegionSize: function (name, size) { + var self = this, o = this.options; + var flag = false; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var clone = this._cloneRegion(); + BI.extend(clone[name], { + width: size.width, + height: size.height + }); + if (this._test(clone)) { + this._modifyRegion(clone); + flag = true; + } + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + var clone = this._cloneRegion(); + BI.extend(clone[name], { + width: size.width, + height: size.height + }); + if (this._test(clone)) { + var layout = this._getLayoutsByRegions(clone); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + flag = true; + } + break; + } + this._applyRegion(); + return flag; + }, + + setPosition: function (position, size) { + var self = this, o = this.options; + var insert, regions = [], cur; + if (position.left < 0 || position.top < 0) { + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.resize(); + break; + } + this._stop(); + this.position = null; + return null; + } + var offset = this._getScrollOffset(); + position = { + left: position.left + offset.left, + top: position.top + offset.top + }; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var insert = { + top: position.top < 0 ? 0 : position.top, + left: position.left < 0 ? 0 : position.left, + width: size.width, + height: size.height + }; + this.position = { + insert: insert + }; + this._setArrangeSize(insert); + this._start(); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + var p = { + top: position.top < 0 ? 0 : position.top, + left: position.left < 0 ? 0 : position.left, + width: size.width, + height: size.height + }; + this._setArrangeSize(p); + var cur = this._getGridPositionAndSize(p); + var layout = [{ + x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i + }].concat(this._getLayoutsByRegions()); + layout = this._moveElement(layout, layout[0], cur.x, cur.y, true); + layout = this.compact(layout, true); + var regions = this._setRegionsByLayout(this._cloneRegion(), layout); + var insert = this._getBlockPositionAndSize(layout[0]); + this.position = { + insert: insert, + regions: regions + }; + this._applyRegion(regions); + this._setBlockPositionAndSize(insert); + this._start(); + break; + } + return this.position; + }, + + setRegionPosition: function (name, position) { + var self = this, o = this.options; + var offset = this._getScrollOffset(); + position = BI.extend(position, { + left: position.left + offset.left, + top: position.top + offset.top + }); + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + this._applyRegion(); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (!position.stop) { + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + var cloned = this._cloneRegion(); + var cur = this._getGridPositionAndSize(BI.extend(cloned[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + })); + var x = cur.x, y = cur.y; + cur = BI.extend(cur, { + x: 0, y: BI.MAX, i: -1 + }); + delete cloned[name]; + var layout = this._getLayoutsByRegions(cloned); + layout = this._moveElement([cur].concat(layout), cur, x, y, true); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + + this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur)); + this.block.setVisible(true); + } else { + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + var cloned = this._cloneRegion(); + var layout = this._getLayoutsByRegions(cloned); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + this.block.setVisible(false); + } + break; + } + }, + + setDropPosition: function (position, size) { + var self = this; + this.arrangement.setVisible(true); + var offset = this._getScrollOffset(); + this._setArrangeSize(BI.extend({}, size, { + left: position.left + offset.left, + top: position.top + offset.top + })); + return function () { + self.arrangement.setVisible(false); + } + }, + + scrollTo: function (scroll) { + this.scrollContainer.element.scrollTop(scroll.top); + this.scrollContainer.element.scrollLeft(scroll.left); + }, + + zoom: function (ratio) { + var self = this, o = this.options; + if (!ratio) { + return; + } + var occupied = this._applyContainer(); + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + if (this._isArrangeFine()) { + var width = this.getClientWidth(); + var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); + //var yRatio = ratio.y * height / (occupied.top + occupied.height); + var regions = this._cloneRegion(); + BI.each(regions, function (i, region) { + region.left = region.left * xRatio; + //region.top = region.top * yRatio; + region.width = region.width * xRatio; + //region.height = region.height * yRatio; + }); + if (this._test(regions)) { + this._modifyRegion(regions); + this._applyRegion(); + } + this.resize(); + // } else { + this.relayout(); + } + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (this._isArrangeFine()) { + var width = this.getClientWidth(), height = this.getClientHeight(); + var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); + var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height); + var regions = this._cloneRegion(); + BI.each(regions, function (i, region) { + region.left = region.left * xRatio; + region.width = region.width * xRatio; + region.top = region.top * yRatio; + region.height = region.height * yRatio; + //做一下自适应布局到网格布局的兼容 + var perWidth = self._getOneWidthPortion(); + var widthPortion = Math.round(region.width / perWidth); + var leftPortion = Math.round(region.left / perWidth); + var comparePortion = Math.round((region.width + region.left) / perWidth); + if (leftPortion + widthPortion !== comparePortion) { + region.left = leftPortion * perWidth; + region.width = comparePortion * perWidth - region.left; + } + }); + if (this._test(regions)) { + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + } + } else { + this.relayout(); + } + break; + } + }, + + resize: function () { + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.zoom(this.ratio); + var regions = this._cloneRegion(); + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + break; + } + }, + + relayout: function () { + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (!this._isArrangeFine()) { + var perHeight = this._getOneHeightPortion(); + var width = this.getClientWidth(), height = this.getClientHeight(); + var regions = this._cloneRegion(); + var clone = BI.toArray(regions); + clone.sort(function (r1, r2) { + if (self._isEqual(r1.top, r2.top)) { + return r1.left - r2.left; + } + return r1.top - r2.top; + }); + var count = clone.length; + var cols = 4, rows = Math.floor((count - 1) / 4 + 1); + var w = width / cols, h = height / rows; + var store = {}; + BI.each(clone, function (i, region) { + var row = Math.floor(i / 4), col = i % 4; + BI.extend(region, { + top: row * perHeight * 6, + left: col * w, + width: w, + height: perHeight * 6 + }); + if (!store[row]) { + store[row] = {}; + } + store[row][col] = region; + }); + //非4的倍数 + // if (count % 4 !== 0) { + // var lasts = store[rows - 1]; + // var perWidth = width / (count % 4); + // BI.each(lasts, function (i, region) { + // BI.extend(region, { + // left: BI.parseInt(i) * perWidth, + // width: perWidth + // }); + // }); + // } + if (this._test(clone)) { + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._populate(clone); + } + } else { + this.resize(); + } + break; + } + }, + + _populate: function (items) { + this._stop(); + this._calculateRegions(items); + this._applyRegion(); + }, + + populate: function (items) { + var self = this; + BI.each(this.regions, function (name, region) { + self.regions[name].el.setVisible(false); + delete self.regions[name]; + }); + this._populate(items); + this._renderRegion(); + } +}); +BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; +BI.extend(BI.Arrangement, { + PORTION: 36, + H_PORTION: 18, + LAYOUT_TYPE: { + GRID: 0, + FREE: 1 + } +}); +BI.shortcut('bi.arrangement', BI.Arrangement);/** + * 表关联树 + * + * Created by GUY on 2015/12/15. + * @class BI.BranchRelation + * @extends BI.Widget + */ +BI.BranchRelation = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.BranchRelation.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-branch-relation-tree", + items: [], + + centerOffset: 0,//重心偏移量 + direction: BI.Direction.Bottom, + align: BI.VerticalAlign.Top + }) + }, + + _init: function () { + BI.BranchRelation.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + //树分层 + _stratification: function () { + var levels = []; + this.tree.recursion(function (node, route) { + //node.isRoot = route.length <= 1; + node.leaf = node.isLeaf(); + if (!levels[route.length - 1]) { + levels[route.length - 1] = []; + } + levels[route.length - 1].push(node); + }); + return levels; + }, + + //计算所有节点的叶子结点个数 + _calculateLeaves: function () { + var count = 0; + + function track(node) { + var c = 0; + if (node.isLeaf()) { + return 1; + } + BI.each(node.getChildren(), function (i, child) { + c += track(child); + }); + node.set("leaves", c); + return c; + } + + count = track(this.tree.getRoot()); + return count; + }, + + //树平移 + _translate: function (levels) { + var adjust = []; + var maxLevel = levels.length; + BI.each(levels, function (i, nodes) { + if (!adjust[i]) { + adjust[i] = []; + } + BI.each(nodes, function (j, node) { + if (node.isLeaf() && i < maxLevel - 1) { + var newNode = new BI.Node(BI.UUID()); + //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot; + newNode.isNew = true; + //把node向下一层移 + var tar = 0; + if (j > 0) { + var c = nodes[j - 1].getLastChild(); + tar = levels[i + 1].indexOf(c) + 1; + } + levels[i + 1].splice(tar, 0, node); + //新增一个临时树节点 + var index = node.parent.getChildIndex(node.id); + node.parent.removeChildByIndex(index); + node.parent.addChild(newNode, index); + newNode.addChild(node); + adjust[i].push(newNode); + nodes[j] = newNode; + } else { + adjust[i].push(node); + } + }) + }); + return adjust; + }, + + //树补白 + _fill: function (levels) { + var adjust = []; + var maxLevel = levels.length; + BI.each(levels, function (i, nodes) { + if (!adjust[i]) { + adjust[i] = []; + } + BI.each(nodes, function (j, node) { + if (node.isLeaf() && i < maxLevel - 1) { + var newNode = new BI.Node(BI.UUID()); + newNode.leaf = true; + newNode.width = node.width; + newNode.height = node.height; + newNode.isNew = true; + //把node向下一层移 + var tar = 0; + if (j > 0) { + var c = nodes[j - 1].getLastChild(); + tar = levels[i + 1].indexOf(c) + 1; + } + levels[i + 1].splice(tar, 0, newNode); + //新增一个临时树节点 + node.addChild(newNode); + } + adjust[i].push(node); + }) + }); + return adjust; + }, + + //树调整 + _adjust: function (adjust) { + while (true) { + var isAllNeedAjust = false; + BI.backEach(adjust, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (!node.isNew) { + var needAdjust = true; + BI.any(node.getChildren(), function (k, n) { + if (!n.isNew) { + needAdjust = false; + return true; + } + }); + if (!node.isLeaf() && needAdjust === true) { + var allChilds = []; + BI.each(node.getChildren(), function (k, n) { + allChilds = allChilds.concat(n.getChildren()); + }); + node.removeAllChilds(); + BI.each(allChilds, function (k, c) { + node.addChild(c); + }); + var newNode = new BI.Node(BI.UUID()); + //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot; + newNode.isNew = true; + var index = node.parent.getChildIndex(node.id); + node.parent.removeChildByIndex(index); + node.parent.addChild(newNode, index); + newNode.addChild(node); + isAllNeedAjust = true; + } + } + }) + }); + if (isAllNeedAjust === false) { + break; + } else {//树重构 + adjust = this._stratification(); + } + } + return adjust; + }, + + _calculateWidth: function () { + var o = this.options; + var width = 0; + + function track1(node) { + var w = 0; + if (node.isLeaf()) { + return node.width; + } + BI.each(node.getChildren(), function (i, child) { + w += track1(child); + }); + return w; + } + + function track2(node) { + var w = 0; + if (node.isLeaf()) { + return node.height; + } + BI.each(node.getChildren(), function (i, child) { + w += track2(child); + }); + return w; + } + + if (this._isVertical()) { + width = track1(this.tree.getRoot()); + } else { + width = track2(this.tree.getRoot()); + } + + return width; + }, + + _isVertical: function () { + var o = this.options; + return o.direction === BI.Direction.Top || o.direction === BI.Direction.Bottom; + }, + + _calculateHeight: function () { + var o = this.options; + var height = 0; + + function track1(node) { + var h = 0; + BI.each(node.getChildren(), function (i, child) { + h = Math.max(h, track1(child)); + }); + return h + (node.height || 0); + } + + function track2(node) { + var h = 0; + BI.each(node.getChildren(), function (i, child) { + h = Math.max(h, track2(child)); + }); + return h + (node.width || 0); + } + + if (this._isVertical()) { + height = track1(this.tree.getRoot()); + } else { + height = track2(this.tree.getRoot()); + } + return height; + }, + + _calculateXY: function (levels) { + var o = this.options; + var width = this._calculateWidth(); + var height = this._calculateHeight(); + var levelCount = levels.length; + var allLeavesCount = this._calculateLeaves(); + //计算坐标 + var xy = {}; + var levelHeight = height / levelCount; + BI.each(levels, function (i, nodes) { + //计算权重 + var weights = []; + BI.each(nodes, function (j, node) { + weights[j] = (node.get("leaves") || 1) / allLeavesCount; + }); + BI.each(nodes, function (j, node) { + //求前j个元素的权重 + var weight = BI.sum(weights.slice(0, j)); + //求坐标 + var x = weight * width + weights[j] * width / 2; + var y = i * levelHeight + levelHeight / 2; + xy[node.id] = {x: x, y: y}; + }) + }); + return xy; + }, + + _stroke: function (levels, xy) { + var height = this._calculateHeight(); + var levelCount = levels.length; + var levelHeight = height / levelCount; + var self = this, o = this.options; + switch (o.direction) { + case BI.Direction.Top: + BI.each(levels, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (node.getChildrenLength() > 0 && !node.leaf) { + var path = ""; + var start = xy[node.id]; + var split = start.y + levelHeight / 2; + path += "M" + start.x + "," + (start.y + o.centerOffset) + "L" + start.x + "," + split; + var end = []; + BI.each(node.getChildren(), function (t, c) { + var e = end[t] = xy[c.id]; + path += "M" + e.x + "," + (e.y + o.centerOffset) + "L" + e.x + "," + split; + }); + if (end.length > 0) { + path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split; + } + self.svg.path(path).attr("stroke", "#d4dadd"); + } + }) + }); + break; + case BI.Direction.Bottom: + BI.each(levels, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (node.getChildrenLength() > 0 && !node.leaf) { + var path = ""; + var start = xy[node.id]; + var split = start.y - levelHeight / 2; + path += "M" + start.x + "," + (start.y - o.centerOffset) + "L" + start.x + "," + split; + var end = []; + BI.each(node.getChildren(), function (t, c) { + var e = end[t] = xy[c.id]; + path += "M" + e.x + "," + (e.y - o.centerOffset) + "L" + e.x + "," + split; + }); + if (end.length > 0) { + path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split; + } + self.svg.path(path).attr("stroke", "#d4dadd"); + } + }) + }); + break; + case BI.Direction.Left: + BI.each(levels, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (node.getChildrenLength() > 0 && !node.leaf) { + var path = ""; + var start = xy[node.id]; + var split = start.y + levelHeight / 2; + path += "M" + (start.y + o.centerOffset) + "," + start.x + "L" + split + "," + start.x; + var end = []; + BI.each(node.getChildren(), function (t, c) { + var e = end[t] = xy[c.id]; + path += "M" + (e.y + o.centerOffset) + "," + e.x + "L" + split + "," + e.x; + }); + if (end.length > 0) { + path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x; + } + self.svg.path(path).attr("stroke", "#d4dadd"); + } + }) + }); + break; + case BI.Direction.Right: + BI.each(levels, function (i, nodes) { + BI.each(nodes, function (j, node) { + if (node.getChildrenLength() > 0 && !node.leaf) { + var path = ""; + var start = xy[node.id]; + var split = start.y - levelHeight / 2; + path += "M" + (start.y - o.centerOffset) + "," + start.x + "L" + split + "," + start.x; + var end = []; + BI.each(node.getChildren(), function (t, c) { + var e = end[t] = xy[c.id]; + path += "M" + (e.y - o.centerOffset) + "," + e.x + "L" + split + "," + e.x; + }); + if (end.length > 0) { + path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x; + } + self.svg.path(path).attr("stroke", "#d4dadd"); + } + }) + }); + break; + } + }, + + _createBranches: function (levels) { + var self = this, o = this.options; + if (o.direction === BI.Direction.Bottom || o.direction === BI.Direction.Right) { + levels = levels.reverse(); + } + var xy = this._calculateXY(levels); + //画图 + this._stroke(levels, xy); + }, + + _isNeedAdjust: function () { + var o = this.options; + return o.direction === BI.Direction.Top && o.align === BI.VerticalAlign.Bottom || o.direction === BI.Direction.Bottom && o.align === BI.VerticalAlign.Top + || o.direction === BI.Direction.Left && o.align === BI.HorizontalAlign.Right || o.direction === BI.Direction.Right && o.align === BI.HorizontalAlign.Left + }, + + setValue: function (value) { + + }, + + getValue: function () { + + }, + + _transformToTreeFormat: 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++) { + 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(sNodes[i]); + } else { + r.push(sNodes[i]); + } + } + return r; + } else { + return [sNodes]; + } + }, + + populate: function (items) { + var self = this, o = this.options; + o.items = items || []; + this.empty(); + items = this._transformToTreeFormat(o.items); + this.tree = new BI.Tree(); + this.tree.initTree(items); + + this.svg = BI.createWidget({ + type: "bi.svg" + }); + + //树分层 + var levels = this._stratification(); + + if (this._isNeedAdjust()) { + //树平移 + var adjust = this._translate(levels); + //树调整 + adjust = this._adjust(adjust); + + this._createBranches(adjust); + } else { + var adjust = this._fill(levels); + + this._createBranches(adjust); + } + + var container = BI.createWidget({ + type: "bi.layout", + width: this._isVertical() ? this._calculateWidth() : this._calculateHeight(), + height: this._isVertical() ? this._calculateHeight() : this._calculateWidth() + }); + BI.createWidget({ + type: "bi.absolute", + element: container, + items: [{ + el: this.svg, + top: 0, + left: 0, + right: 0, + bottom: 0 + }] + }); + if (this._isVertical()) { + items = [{ + type: "bi.handstand_branch_tree", + expander: { + direction: o.direction + }, + el: { + layouts: [{ + type: "bi.horizontal_adapt", + verticalAlign: o.align + }] + }, + items: items + }] + } else { + items = [{ + type: "bi.branch_tree", + expander: { + direction: o.direction + }, + el: { + layouts: [{ + type: "bi.vertical" + }, { + type: o.align === BI.HorizontalAlign.Left ? "bi.left" : "bi.right" + }] + }, + items: items + }] + } + BI.createWidget({ + type: "bi.adaptive", + element: container, + items: items + }); + BI.createWidget({ + type: "bi.center_adapt", + scrollable: true, + element: this, + items: [container] + }); + } +}); +BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE"; +BI.shortcut("bi.branch_relation", BI.BranchRelation);/** + * 日期控件中的月份下拉框 + * + * Created by GUY on 2015/9/7. + * @class BI.MonthDateCombo + * @extends BI.Trigger + */ +BI.MonthDateCombo = BI.inherit(BI.Trigger, { + _defaultConfig: function() { + return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-combo", + height: 25 + }); + }, + _init: function() { + BI.MonthDateCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_triangle_trigger" + }); + + this.popup = BI.createWidget({ + type: "bi.month_popup" + }); + + this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ + self.setValue(self.popup.getValue()); + }) + + + this.combo = BI.createWidget({ + type: "bi.combo", + offsetStyle: "center", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: this.popup + } + }) + this.combo.on(BI.Combo.EVENT_CHANGE, function(){ + self.combo.hideView(); + self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE); + }); + }, + + setValue: function(v){ + this.trigger.setValue(v + 1); + this.popup.setValue(v); + }, + + getValue: function(){ + return this.popup.getValue(); + } +}); +BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.month_date_combo', BI.MonthDateCombo);/** + * 年份下拉框 + * + * Created by GUY on 2015/9/7. + * @class BI.YearDateCombo + * @extends BI.Trigger + */ +BI.YearDateCombo = BI.inherit(BI.Trigger, { + _defaultConfig: function() { + return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-combo", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function() { + BI.YearDateCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_triangle_trigger" + }); + + this.popup = BI.createWidget({ + type: "bi.year_popup", + min: o.min, + max: o.max + }); + + this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); + }) + + + this.combo = BI.createWidget({ + type: "bi.combo", + offsetStyle: "center", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: this.popup + } + }) + this.combo.on(BI.Combo.EVENT_CHANGE, function(){ + self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); + }) + }, + + setValue: function(v){ + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function(){ + return this.popup.getValue(); + } +}); +BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.year_date_combo', BI.YearDateCombo);/** + * Created by GUY on 2015/9/7. + * @class BI.DatePicker + * @extends BI.Widget + */ +BI.DatePicker = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-picker bi-background", + height: 25, + min: '1900-01-01', //最小日期 + max: '2099-12-31' //最大日期 + }) + }, + + _init: function () { + BI.DatePicker.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this._year = new Date().getFullYear(); + this._month = new Date().getMonth(); + this.left = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 25, + height: 25 + }); + this.left.on(BI.IconButton.EVENT_CHANGE, function () { + if (self._month === 0) { + self.setValue({ + year: self.year.getValue() - 1, + month: 11 + }) + } else { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() - 1 + }) + } + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }); + + this.right = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 25, + height: 25 + }); + + this.right.on(BI.IconButton.EVENT_CHANGE, function () { + if (self._month === 11) { + self.setValue({ + year: self.year.getValue() + 1, + month: 0 + }) + } else { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + 1 + }) + } + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }); + + this.year = BI.createWidget({ + type: "bi.year_date_combo", + min: o.min, + max: o.max + }); + this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + }); + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }) + this.month = BI.createWidget({ + type: "bi.month_date_combo" + }); + this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + }); + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.left, + width: 25 + }, { + type: "bi.center_adapt", + items: [{ + type: "bi.horizontal", + width: 100, + items: [this.year, this.month] + }] + }, { + el: this.right, + width: 25 + }] + }) + this.setValue({ + year: this._year, + month: this._month + }) + }, + + setValue: function (ob) { + this._year = ob.year; + this._month = ob.month; + this.year.setValue(ob.year); + this.month.setValue(ob.month); + }, + + getValue: function () { + return { + year: this.year.getValue(), + month: this.month.getValue() + } + } +}); +BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE" +BI.shortcut("bi.date_picker", BI.DatePicker);/** + * Created by GUY on 2015/9/7. + * @class BI.DateCalendarPopup + * @extends BI.Widget + */ +BI.DateCalendarPopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-calendar-popup", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + selectedTime: null + }) + }, + + _createNav: function (v) { + var date = BI.Calendar.getDateJSONByPage(v); + var calendar = BI.createWidget({ + type: "bi.calendar", + logic: { + dynamic: true + }, + min: this.options.min, + max: this.options.max, + year: date.year, + month: date.month, + day: this.selectedTime.day + }); + return calendar; + }, + + _init: function () { + BI.DateCalendarPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.today = new Date(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth(); + this._day = this.today.getDate(); + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month, + day: this._day + }; + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + min: o.min, + max: o.max + }); + + this.calendar = BI.createWidget({ + direction: "top", + element: this, + logic: { + dynamic: true + }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this), + + afterCardCreated: function () { + + }, + + afterCardShow: function () { + this.setValue(self.selectedTime); + } + }); + + this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { + self.selectedTime = self.datePicker.getValue(); + self.selectedTime.day = 1; + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + }); + + this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedTime = self.calendar.getValue(); + self.setValue(self.selectedTime); + self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + }, + + setValue: function (timeOb) { + this.datePicker.setValue(timeOb); + this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb)); + this.calendar.setValue(timeOb); + this.selectedTime = timeOb; + }, + + getValue: function () { + return this.selectedTime; + } +}); +BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/** + * 日期控件中的年份或月份trigger + * + * Created by GUY on 2015/9/7. + * @class BI.DateTriangleTrigger + * @extends BI.Trigger + */ +BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { + _const: { + height: 25, + iconWidth: 16, + iconHeight: 13 + }, + + _defaultConfig: function() { + return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", + height: 25 + }); + }, + _init: function() { + BI.DateTriangleTrigger.superclass._init.apply(this, arguments); + var o = this.options, c = this._const; + this.text = BI.createWidget({ + type: "bi.label", + cls: "list-item-text", + textAlign: "right", + text: o.text, + value: o.value, + height: c.height + }) + this.icon = BI.createWidget({ + type: "bi.icon", + width: c.iconWidth, + height: c.iconHeight + }); + + BI.createWidget({ + type: "bi.center_adapt", + element: this, + items: [{ + type: "bi.center_adapt", + width: 50, + height: c.height, + items: [this.text, this.icon] + }] + }) + }, + + setValue: function(v){ + this.text.setValue(v); + }, + + getValue: function(){ + return this.text.getValue(); + }, + + setText: function(v){ + this.text.setText(v); + }, + + getText: function(){ + return this.item.getText(); + }, + + getKey: function(){ + + } +}); +BI.shortcut('bi.date_triangle_trigger', BI.DateTriangleTrigger);/** + * 日期下拉框 + * + * Created by GUY on 2015/9/7. + * @class BI.DateCombo + * @extends BI.Widget + */ +BI.DateCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-combo bi-border", + height: 30 + }); + }, + _init: function () { + BI.DateCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_trigger" + }); + + this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + + this.popup = BI.createWidget({ + type: "bi.date_calendar_popup" + }); + + this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + width: 270, + el: this.popup, + stopPropagation: false + } + }) + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 30, + yearLength: 4, + yearMonthLength: 7 + }, + + _defaultConfig: function () { + return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-date-trigger", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.DateTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + var date = v.match(/\d+/g); + self._autoAppend(v, date); + return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({ + year: date[0], + month: date[1], + day: date[2] + }); + }, + quitChecker: function () { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + errorText: function () { + if (self.editor.isEditing()) { + return BI.i18nText("BI-Date_Trigger_Error_Text"); + } + return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + } + }); + this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN) + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.DateTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DateTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_VALID, function () { + self.fireEvent(BI.DateTrigger.EVENT_VALID); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DateTrigger.EVENT_ERROR); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setState(value); + } + + if (BI.isNotEmptyString(value)) { + var date = value.split("-"); + self.store_value = { + type: BI.DateTrigger.MULTI_DATE_CALENDAR, + value:{ + year: date[0] | 0, + month: date[1] - 1, + day: date[2] | 0 + } + }; + } + self.fireEvent(BI.DateTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.DateTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTrigger.EVENT_CHANGE); + }); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: BI.createWidget(), + width: 30 + }, { + el: this.editor + }] + }) + }, + _dateCheck: function (date) { + return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; + }, + _checkVoid: function (obj) { + return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; + }, + _autoAppend: function (v, dateObj) { + var self = this; + var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); + var yearCheck = function (v) { + return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max; + }; + var monthCheck = function (v) { + return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max; + }; + if (BI.isNotNull(dateObj) && Date.checkLegal(v)) { + switch (v.length) { + case this._const.yearLength: + if (yearCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + case this._const.yearMonthLength: + if (monthCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + } + } + }, + + setValue: function (v) { + var type, value, self = this; + var date = new Date(); + this.store_value = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value; + if(BI.isNull(value)){ + value = v; + } + } + var _setInnerValue = function (date, text) { + var dateStr = date.print("%Y-%x-%e"); + self.editor.setState(dateStr); + self.editor.setValue(dateStr); + self.setTitle(text + ":" + dateStr); + }; + switch (type) { + case BI.DateTrigger.MULTI_DATE_YEAR_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV]; + date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER]; + date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN]; + date = new Date(date.getFullYear(), 0, 1); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END]; + date = new Date(date.getFullYear(), 11, 31); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV]; + date = new Date().getBeforeMulQuarter(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER]; + date = new Date().getAfterMulQuarter(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN]; + date = new Date().getQuarterStartDate(); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END]; + date = new Date().getQuarterEndDate(); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV]; + date = new Date().getBeforeMultiMonth(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER]; + date = new Date().getAfterMultiMonth(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN]; + date = new Date(date.getFullYear(), date.getMonth(), 1); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END]; + date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_WEEK_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV]; + date = date.getOffsetDate(-7 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_WEEK_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER]; + date = date.getOffsetDate(7 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV]; + date = date.getOffsetDate(-1 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER]; + date = date.getOffsetDate(1 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_TODAY: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY]; + date = new Date(); + _setInnerValue(date, text); + break; + default: + if (BI.isNull(value) || BI.isNull(value.day)) { + this.editor.setState(""); + this.editor.setValue(""); + this.setTitle(""); + } else { + var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day; + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + this.setTitle(dateStr); + } + break; + } + }, + + getKey: function () { + return this.editor.getValue(); + }, + getValue: function () { + return this.store_value; + } + +}); + +BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1; +BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2; +BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3; +BI.DateTrigger.MULTI_DATE_YEAR_END = 4; + +BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5; +BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6; +BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7; +BI.DateTrigger.MULTI_DATE_MONTH_END = 8; + +BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9; +BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10; +BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11; +BI.DateTrigger.MULTI_DATE_QUARTER_END = 12; + +BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13; +BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14; + +BI.DateTrigger.MULTI_DATE_DAY_PREV = 15; +BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16; +BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17; + +BI.DateTrigger.MULTI_DATE_PARAM = 18; +BI.DateTrigger.MULTI_DATE_CALENDAR = 19; + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {}; +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today"); + +BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DateTrigger.EVENT_START = "EVENT_START"; +BI.DateTrigger.EVENT_STOP = "EVENT_STOP"; +BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DateTrigger.EVENT_VALID = "EVENT_VALID"; +BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.shortcut("bi.date_trigger", BI.DateTrigger);/** + * Created by zcf on 2017/2/20. + */ +BI.DatePaneWidget = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DatePaneWidget.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-pane-widget", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + selectedTime: null + }) + }, + _init: function () { + BI.DatePaneWidget.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.today = new Date(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth(); + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month + }; + + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + min: o.min, + max: o.max + }); + this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { + self.selectedTime = self.datePicker.getValue(); + // self.selectedTime.day = 1; + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + }); + + this.calendar = BI.createWidget({ + direction: "top", + element: this, + logic: { + dynamic: false + }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this) + + // afterCardCreated: function () { + // + // }, + // + // afterCardShow: function () { + // // this.setValue(self.selectedTime); + // } + }); + this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedTime = self.calendar.getValue(); + self.calendar.empty(); + self.setValue(self.selectedTime); + self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + + }, + + _createNav: function (v) { + var date = BI.Calendar.getDateJSONByPage(v); + var calendar = BI.createWidget({ + type: "bi.calendar", + logic: { + dynamic: false + }, + min: this.options.min, + max: this.options.max, + year: date.year, + month: date.month, + day: this.selectedTime.day + }); + return calendar; + }, + + _getNewCurrentDate: function () { + var today = new Date(); + return { + year: today.getFullYear(), + month: today.getMonth() + } + }, + + _setCalenderValue: function (date) { + this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date)); + this.calendar.setValue(date); + this.selectedTime = date; + }, + + _setDatePicker: function (timeOb) { + if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) { + this.datePicker.setValue(this._getNewCurrentDate()); + } else { + this.datePicker.setValue(timeOb); + } + }, + + _setCalendar: function (timeOb) { + if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) { + this.calendar.empty(); + this._setCalenderValue(this._getNewCurrentDate()); + } else { + this._setCalenderValue(timeOb) + } + }, + + setValue: function (timeOb) { + this._setDatePicker(timeOb); + this._setCalendar(timeOb); + }, + + getValue: function () { + return this.selectedTime; + } + +}); +BI.shortcut("bi.date_pane_widget", BI.DatePaneWidget);/** + * 带有方向的pathchooser + * + * Created by GUY on 2016/4/21. + * @class BI.DirectionPathChooser + * @extends BI.Widget + */ +BI.DirectionPathChooser = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#808080", + selectLineColor: "#009de3" + }, + + _defaultConfig: function () { + return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table", + items: [] + }); + }, + + _init: function () { + BI.DirectionPathChooser.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.pathChooser = BI.createWidget({ + type: "bi.path_chooser", + element: this, + items: o.items + }); + this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) { + //self._unselectAllArrows(); + self._setValue(start, index); + self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE); + }); + this._drawArrows(); + + }, + + _unselectAllArrows: function () { + var self = this, lineColor = this._const.lineColor; + BI.each(this.arrows, function (region, rs) { + BI.each(rs, function (idx, arrows) { + BI.each(arrows, function (i, arrow) { + arrow.attr({fill: lineColor, stroke: lineColor}); + }); + }); + }); + }, + + _drawOneArrow: function (dot, direction) { + //0,1,2,3 上右下左 + var lineColor = this._const.lineColor; + var selectLineColor = this._const.selectLineColor; + var svg = this.pathChooser.svg; + var path = ""; + switch (direction) { + case 0: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 3) + "," + (dot.y + 5) + + "L" + (dot.x + 3) + "," + (dot.y + 5) + + "L" + dot.x + "," + dot.y; + break; + case 1: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 5) + "," + (dot.y - 3) + + "L" + (dot.x - 5) + "," + (dot.y + 3) + + "L" + dot.x + "," + dot.y; + break; + case 2: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 3) + "," + (dot.y - 5) + + "L" + (dot.x + 3) + "," + (dot.y - 5) + + "L" + dot.x + "," + dot.y; + break; + case 3: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x + 5) + "," + (dot.y - 3) + + "L" + (dot.x + 5) + "," + (dot.y + 3) + + "L" + dot.x + "," + dot.y; + break; + } + return svg.path(path).attr({fill: lineColor, stroke: lineColor}); + }, + + _drawArrows: function () { + var self = this, o = this.options; + var routes = this.pathChooser.routes; + var pathes = this.pathChooser.pathes; + var store = this.pathChooser.store; + this.arrows = {}; + BI.each(routes, function (region, ps) { + self.arrows[region] = []; + BI.each(ps, function (idx, path) { + self.arrows[region][idx] = []; + var dots = pathes[region][idx]; + BI.each(dots, function (i, dot) { + if (i > 0 && i < dots.length - 1) { + var arrow; + if (dot.y === dots[i - 1].y) { + if (dots[i + 1].y != dot.y) { + if (store[path[path.length - 2]].direction === -1) { + if (i - 1 > 0) { + arrow = self._drawOneArrow(dots[i - 1], 3); + } + } else { + arrow = self._drawOneArrow(dots[i], 1); + } + } + } else if (dot.x === dots[i - 1].x) { + if (dot.y > dots[i - 1].y) { + if (store[BI.first(path)].direction === -1) { + arrow = self._drawOneArrow(dots[i - 1], 0); + } else { + arrow = self._drawOneArrow(dot, 2); + } + } else { + if (store[path[path.length - 2]].direction === -1) { + arrow = self._drawOneArrow(dots[i - 1], 2); + } else { + arrow = self._drawOneArrow(dot, 0); + } + } + } + if (arrow) { + self.arrows[region][idx].push(arrow); + } + } + }); + BI.each(path, function (i, node) { + if (i !== 0) { + var arrow; + var from = path[i - 1]; + if (store[from].direction === -1) { + var regionIndex = self.pathChooser.getRegionIndexById(from); + var x = getXoffsetByRegionIndex(regionIndex, -1); + var y = getYByXoffset(dots, x); + arrow = self._drawOneArrow({x: x, y: y}, 3); + } else { + var regionIndex = self.pathChooser.getRegionIndexById(node); + var x = getXoffsetByRegionIndex(regionIndex); + var y = getYByXoffset(dots, x); + arrow = self._drawOneArrow({x: x, y: y}, 1); + } + if (arrow) { + self.arrows[region][idx].push(arrow); + } + } + }); + }) + }); + + function getXoffsetByRegionIndex(regionIndex, diregion) { + if (diregion === -1) { + return 100 * (regionIndex + 1) - 20; + } + return 100 * regionIndex + 20; + } + + function getYByXoffset(dots, xoffset) { + var finded = BI.find(dots, function (i, dot) { + if (i > 0) { + if (dots[i - 1].x < xoffset && dots[i].x > xoffset) { + return true; + } + } + }); + return finded.y; + } + }, + + _setValue: function (start, index) { + var self = this; + var lineColor = this._const.lineColor; + var selectLineColor = this._const.selectLineColor; + var routes = this.pathChooser.routes; + var starts = this.pathChooser.start; + var each = [start]; + if (starts.contains(start)) { + each = starts; + } + BI.each(each, function (i, s) { + BI.each(self.arrows[s], function (j, arrows) { + BI.each(arrows, function (k, arrow) { + arrow.attr({fill: lineColor, stroke: lineColor}).toFront(); + }); + }); + }); + BI.each(this.arrows[start][index], function (i, arrow) { + arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); + }); + var current = BI.last(routes[start][index]); + while (current && routes[current] && routes[current].length === 1) { + BI.each(self.arrows[current][0], function (i, arrow) { + arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); + }); + current = BI.last(routes[current][0]); + } + }, + + setValue: function (v) { + this.pathChooser.setValue(v); + this._unselectAllArrows(); + var routes = this.pathChooser.routes; + var nodes = BI.keys(routes), self = this; + var result = [], array = []; + BI.each(v, function (i, val) { + if (BI.contains(nodes, val)) { + if (array.length > 0) { + array.push(val); + result.push(array); + array = []; + } + } + array.push(val); + }); + if (array.length > 0) { + result.push(array); + } + //画这n条路径 + BI.each(result, function (idx, path) { + var start = path[0]; + var index = BI.findIndex(routes[start], function (idx, p) { + if (BI.isEqual(path, p)) { + return true; + } + }); + if (index >= 0) { + self._setValue(start, index); + } + }); + }, + + getValue: function () { + return this.pathChooser.getValue(); + }, + + populate: function (items) { + this.pathChooser.populate(items); + this._drawArrows(); + } +}); +BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE"; +BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/** + * Created by roy on 15/8/14. + */ +BI.DownListCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-down-list-combo", + invalid: false, + height: 25, + items: [], + adjustLength: 0, + direction: "bottom", + trigger: "click", + el: {} + }) + }, + + _init: function () { + BI.DownListCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.popupview = BI.createWidget({ + type: "bi.down_list_popup", + items: o.items, + chooseType: o.chooseType + }); + + this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) { + self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); + self.downlistcombo.hideView(); + }); + + this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { + self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); + self.downlistcombo.hideView(); + }); + + + this.downlistcombo = BI.createWidget({ + element: this, + type: 'bi.combo', + trigger: o.trigger, + isNeedAdjustWidth: false, + adjustLength: o.adjustLength, + direction: o.direction, + el: BI.createWidget(o.el, { + type: "bi.icon_trigger", + extraCls: o.iconCls ? o.iconCls : "pull-down-font", + width: o.width, + height: o.height + }), + popup: { + el: this.popupview, + stopPropagation: true, + maxHeight: 1000 + } + }); + + this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + hideView: function () { + this.downlistcombo.hideView(); + }, + + showView: function () { + this.downlistcombo.showView(); + }, + + populate: function (items) { + this.popupview.populate(items); + }, + + setValue: function (v) { + this.popupview.setValue(v); + }, + getValue: function () { + return this.popupview.getValue() + } +}); +BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; +BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; + +BI.shortcut("bi.down_list_combo", BI.DownListCombo);/** + * Created by roy on 15/9/6. + */ +BI.DownListGroup = BI.inherit(BI.Widget, { + constants: { + iconCls: "check-mark-ha-font" + }, + _defaultConfig: function () { + return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-down-list-group", + items: [ + { + el: {} + } + ] + }) + }, + _init: function () { + BI.DownListGroup.superclass._init.apply(this, arguments); + var o = this.options, self = this; + + this.downlistgroup = BI.createWidget({ + element: this, + type: "bi.button_tree", + items: o.items, + chooseType: 0,//0单选,1多选 + layouts: [{ + type: "bi.vertical", + hgap: 0, + vgap: 0 + }] + }); + this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if(type === BI.Events.CLICK) { + self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments); + } + }) + }, + getValue:function(){ + return this.downlistgroup.getValue(); + }, + setValue:function(v){ + this.downlistgroup.setValue(v); + } + + +}) +BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.Single, { + _defaultConfig: function () { + var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-down-list-item bi-list-item-active", + cls: "", + height: 25, + logic: { + dynamic: true + }, + selected: false, + iconHeight: null, + iconWidth: null, + textHgap: 0, + textVgap: 0, + textLgap: 0, + textRgap: 0 + }) + }, + _init: function () { + BI.DownListItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.text = BI.createWidget({ + type: "bi.icon_text_item", + element: this, + height: o.height, + text: o.text, + value: o.value, + logic: o.logic, + selected: o.selected, + disabled: o.disabled, + iconHeight: o.iconHeight, + iconWidth: o.iconWidth, + textHgap: o.textHgap, + textVgap: o.textVgap, + textLgap: o.textLgap, + textRgap: o.textRgap, + father: o.father + }); + this.text.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.text.on(BI.IconTextItem.EVENT_CHANGE, function () { + self.fireEvent(BI.DownListItem.EVENT_CHANGE); + }); + // this.setSelected(o.selected); + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + isSelected: function () { + return this.text.isSelected(); + }, + + setSelected: function (b) { + this.text.setSelected(b); + // if (b === true) { + // this.element.addClass("dot-e-font"); + // } else { + // this.element.removeClass("dot-e-font"); + // } + }, + + setValue: function (v) { + this.text.setValue(v); + }, + + getValue: function () { + return this.text.getValue(); + } +}); +BI.DownListItem.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-down-list-group-item", + logic: { + dynamic: false + }, + // invalid: true, + iconCls1: "dot-e-font", + iconCls2: "pull-right-e-font" + }) + }, + _init: function () { + BI.DownListGroupItem.superclass._init.apply(this, arguments); + var o = this.options; + var self = this; + this.text = BI.createWidget({ + type: "bi.label", + cls: "list-group-item-text", + textAlign: "left", + text: o.text, + value: o.value, + height: o.height + }); + + this.icon1 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls1, + width: 25, + forceNotSelected: true + }); + + this.icon2 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls2, + width: 25, + forceNotSelected: true + }); + + var blank = BI.createWidget({ + type: "bi.layout", + width: 25 + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.icon2, + top: 0, + bottom: 0, + right: 0 + }] + }); + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { + items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank) + })))); + + this.element.hover(function () { + if (self.isEnabled()) { + self.hover(); + } + }, function () { + if (self.isEnabled()) { + self.dishover() + } + }); + }, + + hover: function () { + BI.DownListGroupItem.superclass.hover.apply(this, arguments); + this.icon1.element.addClass("hover"); + this.icon2.element.addClass("hover"); + + }, + + dishover: function () { + BI.DownListGroupItem.superclass.dishover.apply(this, arguments); + this.icon1.element.removeClass("hover"); + this.icon2.element.removeClass("hover"); + }, + + doClick: function () { + BI.DownListGroupItem.superclass.doClick.apply(this, arguments); + if (this.isValid()) { + this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue()); + } + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + setValue: function (v) { + var self = this, o = this.options; + v = BI.isArray(v) ? v : [v]; + BI.find(v, function (idx, value) { + if (BI.contains(o.childValues, value)) { + self.icon1.setSelected(true); + return true; + } else { + self.icon1.setSelected(false); + } + }) + } +}); +BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/** + * Created by roy on 15/9/8. + * 处理popup中的item分组样式 + * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项 + */ +BI.DownListPopup = BI.inherit(BI.Pane, { + constants: { + nextIcon: "pull-right-e-font", + height: 25, + iconHeight: 12, + iconWidth: 12, + hgap: 0, + vgap: 0, + border: 1 + }, + _defaultConfig: function () { + var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-down-list-popup", + items: [], + chooseType: BI.Selection.Multi + }) + }, + _init: function () { + BI.DownListPopup.superclass._init.apply(this, arguments); + this.singleValues = []; + this.childValueMap = {}; + this.fatherValueMap = {}; + var self = this, o = this.options, children = this._createChildren(o.items); + this.popup = BI.createWidget({ + type: "bi.button_tree", + items: BI.createItems(children, + {}, { + adjustLength: -2 + } + ), + layouts: [{ + type: "bi.vertical", + hgap: this.constants.hgap, + vgap: this.constants.vgap + }], + chooseType: o.chooseType + }); + + this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) { + var changedValue = value; + if (BI.isNotNull(self.childValueMap[value])) { + changedValue = self.childValueMap[value]; + self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value]) + } else { + self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object); + } + + + if (!self.singleValues.contains(changedValue)) { + var item = self.getValue(); + var result = []; + BI.each(item, function (i, valueObject) { + if (valueObject.value != changedValue) { + result.push(valueObject); + } + }); + self.setValue(result); + } + + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.popup] + }); + + }, + _createChildren: function (items) { + var self = this, result = []; + BI.each(items, function (i, it) { + var item_done = { + type: "bi.down_list_group", + items: [] + }; + + BI.each(it, function (i, item) { + if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) { + item.type = "bi.combo_group"; + item.cls = "down-list-group"; + item.trigger = "hover"; + item.isNeedAdjustWidth = false; + item.el.title = item.el.title || item.el.text; + item.el.type = "bi.down_list_group_item"; + item.el.logic = { + dynamic: true + }; + item.el.height = self.constants.height; + item.el.iconCls2 = self.constants.nextIcon; + item.popup = { + lgap: 4, + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical" + }] + + } + }; + item.el.childValues = []; + BI.each(item.children, function (i, child) { + var fatherValue = BI.deepClone(item.el.value); + var childValue = BI.deepClone(child.value); + self.singleValues.push(child.value); + child.type = "bi.down_list_item"; + child.extraCls = " child-down-list-item"; + child.title = child.title || child.text; + child.textRgap = 10; + child.isNeedAdjustWidth = false; + child.logic = { + dynamic: true + }; + child.father = fatherValue; + self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; + self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; + child.value = self._createChildValue(fatherValue, childValue); + item.el.childValues.push(child.value); + }) + } else { + item.type = "bi.down_list_item"; + item.title = item.title || item.text; + item.textRgap = 10; + item.isNeedAdjustWidth = false; + item.logic = { + dynamic: true + } + } + var el_done = {}; + el_done.el = item; + item_done.items.push(el_done); + }); + if (self._isGroup(item_done.items)) { + BI.each(item_done.items, function (i, item) { + self.singleValues.push(item.el.value); + }) + } + + result.push(item_done); + if (self._needSpliter(i, items.length)) { + var spliter_container = BI.createWidget({ + type: "bi.vertical", + items: [{ + el: { + type: "bi.layout", + cls: "bi-down-list-spliter bi-border-top cursor-pointer", + height: 0 + } + + }], + cls: "bi-down-list-spliter-container cursor-pointer", + lgap: 10, + rgap: 10 + }); + result.push(spliter_container); + } + }); + return result; + }, + + _isGroup: function (i) { + return i.length > 1; + }, + + _needSpliter: function (i, itemLength) { + return i < itemLength - 1; + }, + + _createChildValue: function (fatherValue, childValue) { + return fatherValue + "_" + childValue + }, + + populate: function (items) { + BI.DownListPopup.superclass.populate.apply(this, arguments); + var self = this; + self.childValueMap = {}; + self.fatherValueMap = {}; + self.singleValues = []; + var children = self._createChildren(items); + var popupItem = BI.createItems(children, + {}, { + adjustLength: -2 + } + ); + self.popup.populate(popupItem); + }, + + setValue: function (valueItem) { + var self = this; + var valueArray = []; + BI.each(valueItem, function (i, item) { + var value; + if (BI.isNotNull(item.childValue)) { + value = self._createChildValue(item.value, item.childValue); + } else { + value = item.value; + } + valueArray.push(value); + } + ); + this.popup.setValue(valueArray); + }, + + getValue: function () { + var self = this, result = []; + var values = this.popup.getValue(); + BI.each(values, function (i, value) { + var valueItem = {}; + if (BI.isNotNull(self.childValueMap[value])) { + var fartherValue = self.fatherValueMap[value]; + valueItem.childValue = self.childValueMap[value]; + valueItem.value = fartherValue; + } else { + valueItem.value = value; + } + result.push(valueItem); + }); + return result; + } + + +}); + +BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; +BI.shortcut("bi.down_list_popup", BI.DownListPopup);/** + * + * Created by GUY on 2016/3/28. + * @class BI.ExcelTableCell + * @extends BI.Widget + */ +BI.ExcelTableCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ExcelTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table-cell", + text: "" + }); + }, + + _init: function () { + BI.ExcelTableCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.excel_table_cell', BI.ExcelTableCell);/** + * + * Created by GUY on 2016/3/28. + * @class BI.ExcelTableHeaderCell + * @extends BI.Widget + */ +BI.ExcelTableHeaderCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ExcelTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table-header-cell bi-background", + text: "" + }); + }, + + _init: function () { + BI.ExcelTableHeaderCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: BI.HorizontalAlign.Center, + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.excel_table_header_cell', BI.ExcelTableHeaderCell);/** + * Excel表格 + * + * Created by GUY on 2016/3/28. + * @class BI.ExcelTable + * @extends BI.Widget + */ +BI.ExcelTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table", + el: { + type: "bi.responsive_table" + }, + + isNeedResize: false, + isResizeAdapt: true, + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 + return BI.isEqual(row1, row2); + }, + + columnSize: [], + headerRowSize: 37, + footerRowSize: 37, + rowSize: 37, + + regionColumnSize: false, + + items: [] //二维数组 + }); + }, + + _init: function () { + BI.ExcelTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var mergeCols = []; + BI.each(o.mergeCols, function (i, col) { + mergeCols.push(col + 1); + }); + this.table = BI.createWidget(o.el, { + type: "bi.table_view", + element: this, + + isNeedFreeze: false, + + isNeedMerge: o.isNeedMerge, + mergeCols: mergeCols, + mergeRule: o.mergeRule, + + columnSize: [""].concat(o.columnSize), + headerRowSize: 18, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize || [82, ""] + }); + + if (BI.isNotEmptyArray(o.items)) { + this.populate(o.items); + } + BI.nextTick(function () { + self.setRegionColumnSize(o.regionColumnSize || [82, ""]); + }); + }, + + resize: function () { + this.table.resize(); + }, + + setColumnSize: function (columnSize) { + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + this.table.setHeaderColumnSize(columnSize); + }, + + setRegionColumnSize: function (columnSize) { + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize(); + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize(); + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + resizeHeader: function () { + this.table.resize(); + this.table._resizeHeader && this.table._resizeHeader(); + }, + + attr: function (key,value) { + var self = this; + if (BI.isObject(key)) { + BI.each(key, function (k, v) { + self.attr(k, v); + }); + return; + } + BI.ExcelTable.superclass.attr.apply(this, arguments); + switch (key){ + case "mergeCols": + var mCols = []; + BI.each(value, function (i, col) { + mCols.push(col + 1); + }); + value=mCols; + break; + } + this.table.attr.apply(this.table, arguments); + }, + + populate: function (rows) { + var self = this; + var columnSize = this.getColumnSize(); + var items = []; + var header = [{ + type: "bi.excel_table_header_cell" + }]; + if (BI.isNotNull(rows)) { + BI.each(columnSize, function (i, size) { + header.push({ + type: "bi.excel_table_header_cell", + text: BI.int2Abc(i + 1) + }); + }); + BI.each(rows, function (i, row) { + items.push([{ + type: "bi.excel_table_header_cell", + text: (i + 1) + }].concat(row)); + }); + } + this.table.populate(items, [header]); + }, + + destroy: function () { + this.table.destroy(); + BI.ExcelTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.excel_table', BI.ExcelTable);/** + * 文件管理控件组 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerButtonGroup + * @extends BI.Widget + */ +BI.FileManagerButtonGroup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-button_group", + items: [] + }) + }, + + _init: function () { + BI.FileManagerButtonGroup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.button_group = BI.createWidget({ + type: "bi.button_tree", + element: this, + chooseType: BI.Selection.Multi, + items: this._formatItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + _formatItems: function (items) { + var self = this, o = this.options; + BI.each(items, function (i, item) { + if (item.children && item.children.length > 0) { + item.type = "bi.file_manager_folder_item"; + } else { + item.type = "bi.file_manager_file_item"; + } + }); + return items; + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getNotSelectedValue: function () { + return this.button_group.getNotSelectedValue(); + }, + + getAllLeaves: function () { + return this.button_group.getAllLeaves(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + getSelectedButtons: function () { + return this.button_group.getSelectedButtons(); + }, + + getNotSelectedButtons: function () { + return this.button_group.getNotSelectedButtons(); + }, + + populate: function (items) { + this.button_group.populate(this._formatItems(items)); + } +}); +BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManager + * @extends BI.Widget + */ +BI.FileManager = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager", + el: {}, + items: [] + }) + }, + + _init: function () { + BI.FileManager.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + var items = BI.Tree.transformToTreeFormat(o.items); + this.tree.initTree(items); + this.selectedValues = []; + this.nav = BI.createWidget({ + type: "bi.file_manager_nav", + items: BI.deepClone(items) + }); + this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) { + if (value == "-1") {//根节点 + self.populate({children: self.tree.toJSON()}); + } else { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } + self.setValue(self.selectedValues); + }); + this.list = BI.createWidget(o.el, { + type: "bi.file_manager_list", + items: items + }); + this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) { + if (type === BI.Events.CHANGE) { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } else if (type === BI.Events.CLICK) { + var values = []; + if (obj instanceof BI.MultiSelectBar) { + var t = self.list.getValue(); + selected = t.type === BI.Selection.All; + values = BI.concat(t.assist, t.value); + } else { + values = obj.getAllLeaves(); + } + BI.each(values, function (i, v) { + if (selected === true) { + self.selectedValues.pushDistinct(v); + } else { + self.selectedValues.remove(v); + } + }); + } + self.setValue(self.selectedValues); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.list, + left: 0, + right: 0, + top: 0, + bottom: 10 + }, { + el: this.nav, + left: 40, + right: 100, + top: 0 + }] + }); + }, + + setValue: function (value) { + this.selectedValues = value || []; + this.list.setValue(this.selectedValues); + }, + + getValue: function () { + var obj = this.list.getValue(); + var res = obj.type === BI.Selection.All ? obj.assist : obj.value; + res.pushDistinctArray(this.selectedValues); + return res; + }, + + _populate: function (items) { + this.list.populate(items); + }, + + getSelectedValue: function () { + return this.nav.getValue()[0]; + }, + + getSelectedId: function () { + return this.nav.getId()[0]; + }, + + populate: function (node) { + var clone = BI.deepClone(node); + this._populate(node.children); + this.nav.populate(clone); + } +}); +BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE"; +BI.shortcut("bi.file_manager", BI.FileManager);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFileItem + * @extends BI.Single + */ +BI.FileManagerFileItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom", + height: 30 + }) + }, + + _init: function () { + BI.FileManagerFileItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-file-font" + }, + width: 20 + }, { + el: { + type: "bi.label", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + } + }] + }) + }, + + getAllLeaves: function(){ + return [this.options.value]; + }, + + isSelected: function () { + return this.checked.isSelected(); + }, + + setSelected: function (v) { + this.checked.setSelected(v); + } +}); +BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFolderItem + * @extends BI.Single + */ +BI.FileManagerFolderItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom", + height: 30 + }) + }, + + _init: function () { + BI.FileManagerFolderItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button = BI.createWidget({ + type: "bi.text_button", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self); + }); + + this.tree = new BI.Tree(); + this.tree.initTree([{ + id: o.id, + children: o.children + }]); + this.selectValue = []; + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-folder-font" + }, + width: 20 + }, { + el: this.button + }] + }) + }, + + setAllSelected: function (v) { + this.checked.setSelected(v); + this.selectValue = []; + }, + + setHalfSelected: function (v) { + this.checked.setHalfSelected(v); + if(!v){ + this.selectValue = []; + } + }, + + setValue: function (v) { + var self = this, o = this.options; + var isHalf = false; + var selectValue = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + if (BI.contains(v, node.get("data").value)) { + selectValue.push(node.get("data").value); + } else { + isHalf = true; + } + } + }); + this.setAllSelected(selectValue.length > 0 && !isHalf); + this.setHalfSelected(selectValue.length > 0 && isHalf); + if (this.checked.isHalfSelected()) { + this.selectValue = selectValue; + } + }, + + getAllButtons: function () { + return [this]; + }, + + getAllLeaves: function () { + var o = this.options; + var res = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value) + } + }); + return res; + }, + + getNotSelectedValue: function () { + var self = this, o = this.options; + var res = []; + var isAllSelected = this.checked.isSelected(); + if (isAllSelected === true) { + return res; + } + var isHalfSelected = this.checked.isHalfSelected(); + this.tree.traverse(function (node) { + if (node.isLeaf()) { + var v = node.get("data").value; + if (isHalfSelected === true) { + if (!BI.contains(self.selectValue, node.get("data").value)) { + res.push(v); + } + } else { + res.push(v); + } + } + }); + return res; + }, + + getValue: function () { + var res = []; + if (this.checked.isSelected()) { + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value); + } + }); + return res; + } + if (this.checked.isHalfSelected()) { + return this.selectValue; + } + return []; + } +}); +BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/** + * 文件管理控件列表 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerList + * @extends BI.Widget + */ +BI.FileManagerList = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-list", + el: {}, + items: [] + }) + }, + + _init: function () { + BI.FileManagerList.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.list = BI.createWidget({ + type: "bi.select_list", + element: this, + items: o.items, + toolbar: { + type: "bi.multi_select_bar", + height: 40, + text: "" + }, + el: { + type: "bi.list_pane", + el: BI.isWidget(o.el) ? o.el : BI.extend({ + type: "bi.file_manager_button_group" + }, o.el) + } + }); + this.list.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + setValue: function (v) { + this.list.setValue({ + value: v + }); + }, + + getValue: function () { + return this.list.getValue(); + }, + + populate: function (items) { + this.list.populate(items); + this.list.setToolBarVisible(true); + } +}); +BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_list", BI.FileManagerList);/** + * 文件管理导航按钮 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNavButton + * @extends BI.Widget + */ +BI.FileManagerNavButton = BI.inherit(BI.Widget, { + + _const: { + normal_color: "#ffffff", + select_color: "#f4f4f4" + }, + _defaultConfig: function () { + return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav-button", + selected: false, + height: 40 + }) + }, + + _init: function () { + BI.FileManagerNavButton.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.button = BI.createWidget({ + type: "bi.text_button", + cls: "file-manager-nav-button-text bi-card", + once: true, + selected: o.selected, + text: o.text, + title: o.text, + value: o.value, + height: o.height, + lgap: 20, + rgap: 10 + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + var svg = BI.createWidget({ + type: "bi.svg", + cls: "file-manager-nav-button-triangle", + width: 15, + height: o.height + }); + var path = svg.path("M0,0L15,20L0,40").attr({ + "stroke": c.select_color, + "fill": o.selected ? c.select_color : c.normal_color + }); + this.button.on(BI.TextButton.EVENT_CHANGE, function () { + if (this.isSelected()) { + path.attr("fill", c.select_color); + } else { + path.attr("fill", c.normal_color); + } + }); + BI.createWidget({ + type: "bi.default", + element: this, + items: [this.button] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: svg, + right: -15, + top: 0, + bottom: 0 + }] + }) + }, + + isSelected: function () { + return this.button.isSelected(); + }, + + setValue: function (v) { + this.button.setValue(v); + }, + + getValue: function () { + return this.button.getValue(); + }, + + populate: function (items) { + + } +}); +BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/** + * 文件管理导航 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNav + * @extends BI.Widget + */ +BI.FileManagerNav = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav bi-border-left", + height: 40, + items: [] + }) + }, + + _init: function () { + BI.FileManagerNav.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + this.refreshTreeData(o.items); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + this.button_group = BI.createWidget({ + type: "bi.button_group", + element: this, + items: [{ + type: "bi.file_manager_nav_button", + text: BI.i18nText("BI-Created_By_Me"), + selected: true, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME, + value: BI.FileManagerNav.ROOT_CREATE_BY_ME + }], + layouts: [{ + type: "bi.horizontal" + }] + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) { + self.fireEvent(BI.FileManagerNav.EVENT_CHANGE, arguments); + }); + }, + + _getAllParents: function (id) { + var node, res = []; + if (!id) { + node = this.tree.getRoot(); + } else { + node = this.tree.search(id); + } + while (node.parent) { + res.push(node); + node = node.parent; + } + res.push(node); + return res.reverse(); + }, + + _formatNodes: function (nodes) { + var res = []; + BI.each(nodes, function (i, node) { + res.push(BI.extend({ + type: "bi.file_manager_nav_button", + id: node.id + }, node.get("data"))); + }); + BI.last(res).selected = true; + return res; + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getId: function () { + var ids = []; + BI.each(this.button_group.getSelectedButtons(), function (i, btn) { + ids.push(btn.attr("id")); + }); + return ids; + }, + + refreshTreeData: function(items){ + this.tree.initTree(BI.Tree.transformToTreeFormat(items)); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + }, + + populate: function (node) { + var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id); + this.button_group.populate(this._formatNodes(parents)); + } +}); +BI.extend(BI.FileManagerNav, { + ROOT_CREATE_BY_ME: "-1" +}); +BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** + * Created by windy on 2017/3/13. + * 数值微调器 + */ +BI.FineTuningNumberEditor = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-fine-tuning-number-editor bi-border", + value: -1 + }) + }, + + _init: function () { + BI.FineTuningNumberEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + value: this._alertInEditorValue(o.value), + errorText: BI.i18nText("BI-Please_Input_Natural_Number"), + validationChecker: function(v){ + return BI.isNaturalNumber(v) || self._alertOutEditorValue(v) === -1; + } + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){ + self._finetuning(0); + self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(1); + self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); + }); + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(-1); + self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); + }); + this._finetuning(0); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [this.editor, { + el: { + type: "bi.grid", + columns: 1, + rows: 2, + items: [{ + column: 0, + row: 0, + el: this.topBtn + }, { + column: 0, + row: 1, + el: this.bottomBtn + }] + }, + width: 30 + }] + }); + }, + + _alertOutEditorValue: function(v){ + return v === BI.i18nText("BI-Basic_Auto") ? -1 : v; + }, + + _alertInEditorValue: function(v){ + return BI.parseInt(v) === -1 ? BI.i18nText("BI-Basic_Auto") : v; + }, + + //微调 + _finetuning: function(add){ + var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); + this.editor.setValue(this._alertInEditorValue(v + add)); + this.bottomBtn.setEnable((v + add) > -1); + }, + + getValue: function () { + var v = this.editor.getValue(); + return this._alertOutEditorValue(v); + }, + + setValue: function (v) { + this.editor.setValue(this._alertInEditorValue(v)); + this._finetuning(0); + } + +}); +BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);/** + * 交互行为布局 + * + * + * Created by GUY on 2016/7/23. + * @class BI.InteractiveArrangement + * @extends BI.Widget + */ +BI.InteractiveArrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-interactive-arrangement", + resizable: true, + layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, + items: [] + }); + }, + + _init: function () { + BI.InteractiveArrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.adaptive_arrangement", + element: this, + resizable: o.resizable, + layoutType: o.layoutType, + items: o.items + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () { + self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments); + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () { + self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments); + }); + + this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) { + var p = self._getRegionClientPosition(id); + self.draw({ + left: p.left, + top: p.top + }, size, id); + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) { + self.stopDraw(); + self.setRegionSize(id, size); + }); + + this.tags = []; + + }, + + _isEqual: function (num1, num2) { + return this.arrangement._isEqual(num1, num2); + }, + + _getScrollOffset: function () { + return this.arrangement._getScrollOffset(); + }, + + _positionAt: function (position, regions) { + var self = this; + regions = regions || this.getAllRegions(); + var left = [], center = [], right = [], top = [], middle = [], bottom = []; + BI.each(regions, function (i, region) { + var client = self._getRegionClientPosition(region.id); + if (Math.abs(client.left - position.left) <= 3) { + left.push(region); + } + if (Math.abs(client.left + client.width / 2 - position.left) <= 3) { + center.push(region); + } + if (Math.abs(client.left + client.width - position.left) <= 3) { + right.push(region); + } + if (Math.abs(client.top - position.top) <= 3) { + top.push(region); + } + if (Math.abs(client.top + client.height / 2 - position.top) <= 3) { + middle.push(region); + } + if (Math.abs(client.top + client.height - position.top) <= 3) { + bottom.push(region); + } + }); + return { + left: left, + center: center, + right: right, + top: top, + middle: middle, + bottom: bottom + } + }, + + _getRegionClientPosition: function (name) { + var region = this.getRegionByName(name); + var offset = this.arrangement._getScrollOffset(); + return { + top: region.top - offset.top, + left: region.left - offset.left, + width: region.width, + height: region.height, + id: region.id + } + }, + + _vAlign: function (position, regions) { + var self = this; + var vs = this._positionAt(position, regions); + var positions = []; + var l; + if (vs.left.length > 0) { + l = this._getRegionClientPosition(vs.left[0].id).left; + } else if (vs.right.length > 0) { + var temp = this._getRegionClientPosition(vs.right[0].id); + l = temp.left + temp.width; + } + var rs = vs.left.concat(vs.right); + BI.each(rs, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l)) { + var topPoint = { + top: p.top + p.height / 2, + left: l + }; + positions.push({ + id: region.id, + start: topPoint, + end: { + left: l, + top: position.top + } + }); + } + }); + return positions; + }, + + _leftAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left, + top: position.top + size.height / 2 + }, regions); + }, + + _rightAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left + size.width, + top: position.top + size.height / 2 + }, regions); + }, + + _hAlign: function (position, regions) { + var self = this; + var hs = this._positionAt(position, regions); + var positions = []; + var t; + if (hs.top.length > 0) { + var temp = this._getRegionClientPosition(hs.top[0].id); + t = temp.top; + } else if (hs.bottom.length > 0) { + var temp = this._getRegionClientPosition(hs.bottom[0].id); + t = temp.top + temp.height; + } + var rs = hs.top.concat(hs.bottom); + BI.each(rs, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t)) { + var leftPoint = { + top: t, + left: p.left + p.width / 2 + }; + positions.push({ + id: p.id, + start: leftPoint, + end: { + left: position.left, + top: t + } + }); + } + }); + return positions; + }, + + _topAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + }, regions); + }, + + _bottomAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + size.height + }, regions); + }, + + _centerAlign: function (position, size, regions) { + var self = this; + var cs = this._positionAt({ + left: position.left + size.width / 2, + top: position.top + size.height / 2 + }, regions); + var positions = []; + var l; + if (cs.center.length > 0) { + var temp = this._getRegionClientPosition(cs.center[0].id); + l = temp.left + temp.width / 2; + } + BI.each(cs.center, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.left + p.width / 2, l)) { + var topPoint = { + top: p.top + p.height / 2, + left: p.left + p.width / 2 + }; + positions.push({ + id: p.id, + start: topPoint, + end: { + left: l, + top: position.top + size.height / 2 + } + }); + } + }); + return positions; + }, + + _middleAlign: function (position, size, regions) { + var self = this; + var cs = this._positionAt({ + left: position.left + size.width / 2, + top: position.top + size.height / 2 + }, regions); + var positions = []; + var t; + if (cs.middle.length > 0) { + var temp = this._getRegionClientPosition(cs.middle[0].id); + t = temp.top + temp.height / 2; + } + BI.each(cs.middle, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.top + p.height / 2, t)) { + var topPoint = { + top: p.top + p.height / 2, + left: p.left + p.width / 2 + }; + positions.push({ + id: p.id, + start: topPoint, + end: { + left: position.left + size.width / 2, + top: t + } + }); + } + }); + return positions; + }, + + + _drawOneTag: function (start, end) { + var s = BI.createWidget({ + type: "bi.icon_button", + //invisible: true, + width: 13, + height: 13, + cls: "drag-tag-font interactive-arrangement-dragtag-icon" + }); + var e = BI.createWidget({ + type: "bi.icon_button", + //invisible: true, + width: 13, + height: 13, + cls: "drag-tag-font interactive-arrangement-dragtag-icon" + }); + if (this._isEqual(start.left, end.left)) { + var line = BI.createWidget({ + type: "bi.layout", + //invisible: true, + cls: "interactive-arrangement-dragtag-line", + width: 1, + height: Math.abs(start.top - end.top) + }); + } else { + var line = BI.createWidget({ + type: "bi.layout", + //invisible: true, + cls: "interactive-arrangement-dragtag-line", + height: 1, + width: Math.abs(start.left - end.left) + }); + } + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: s, + left: start.left - 6, + top: start.top - 7 + }, { + el: e, + left: end.left - 6, + top: end.top - 7 + }, { + el: line, + left: Math.min(start.left, end.left), + top: Math.min(start.top, end.top) + }] + }); + this.tags.push(s); + this.tags.push(e); + this.tags.push(line); + }, + + stopDraw: function () { + BI.each(this.tags, function (i, w) { + w.destroy(); + }); + this.tags = []; + }, + + _getRegionExcept: function (name, regions) { + var other = []; + BI.each(regions || this.getAllRegions(), function (i, region) { + if (!(name && region.id === name)) { + other.push(region); + } + }); + return other; + }, + + getClientWidth: function () { + return this.arrangement.getClientWidth(); + }, + + getClientHeight: function () { + return this.arrangement.getClientHeight(); + }, + + getPosition: function (name, position, size) { + var regions = this.getAllRegions(); + var me; + if (name) { + me = this._getRegionClientPosition(name); + } + var other = this._getRegionExcept(name, regions); + position = position || { + left: me.left, + top: me.top + }; + size = size || { + width: me.width, + height: me.height + }; + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + position.left = pos.end.left - size.width / 2; + }); + BI.each(right, function (i, pos) { + position.left = pos.end.left - size.width; + }); + BI.each(left, function (i, pos) { + position.left = pos.end.left; + }); + BI.each(middle, function (i, pos) { + position.top = pos.end.top - size.height / 2; + }); + BI.each(bottom, function (i, pos) { + position.top = pos.end.top - size.height; + }); + BI.each(top, function (i, pos) { + position.top = pos.end.top; + }); + return position; + }, + + //position不动 变size + getSize: function (name, position, size) { + var regions = this.getAllRegions(); + var me; + if (name) { + me = this._getRegionClientPosition(name); + } + var other = this._getRegionExcept(name, regions); + position = position || { + left: me.left, + top: me.top + }; + size = size || { + width: me.width, + height: me.height + }; + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + size.width = (pos.end.left - position.left) * 2; + }); + BI.each(right, function (i, pos) { + size.width = pos.end.left - position.left; + }); + BI.each(left, function (i, pos) { + }); + BI.each(middle, function (i, pos) { + size.height = (pos.end.top - position.top) * 2; + }); + BI.each(bottom, function (i, pos) { + size.height = pos.end.top - position.top; + }); + BI.each(top, function (i, pos) { + }); + return size; + }, + + draw: function (position, size, name) { + var self = this; + this.stopDraw(); + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var other = this._getRegionExcept(name); + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(right, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(left, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(middle, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(bottom, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(top, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + }, + + addRegion: function (region, position) { + this.stopDraw(); + return this.arrangement.addRegion(region, position); + }, + + deleteRegion: function (name) { + return this.arrangement.deleteRegion(name); + }, + + setRegionSize: function (name, size) { + size = this.getSize(name, null, size); + return this.arrangement.setRegionSize(name, size); + }, + + setPosition: function (position, size) { + var self = this; + this.stopDraw(); + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(null, position, size); + this.draw(position, size); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + var at = this.arrangement.setPosition(position, size); + return at; + }, + + setRegionPosition: function (name, position) { + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(name, position); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + return this.arrangement.setRegionPosition(name, position); + }, + + setDropPosition: function (position, size) { + var self = this; + this.stopDraw(); + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(null, position, size); + this.draw(position, size); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + var callback = self.arrangement.setDropPosition(position, size); + return function () { + callback(); + self.stopDraw(); + } + }, + + scrollInterval: function () { + this.arrangement.scrollInterval.apply(this.arrangement, arguments); + }, + + scrollEnd: function () { + this.arrangement.scrollEnd.apply(this.arrangement, arguments); + }, + + scrollTo: function (scroll) { + this.arrangement.scrollTo(scroll); + }, + + zoom: function (ratio) { + this.arrangement.zoom(ratio); + }, + + resize: function () { + return this.arrangement.resize(); + }, + + relayout: function () { + return this.arrangement.relayout(); + }, + + setLayoutType: function (type) { + this.arrangement.setLayoutType(type); + }, + + getLayoutType: function () { + return this.arrangement.getLayoutType(); + }, + + getLayoutRatio: function () { + return this.arrangement.getLayoutRatio(); + }, + + getHelper: function () { + return this.arrangement.getHelper(); + }, + + getRegionByName: function (name) { + return this.arrangement.getRegionByName(name); + }, + + getAllRegions: function () { + return this.arrangement.getAllRegions(); + }, + + revoke: function () { + return this.arrangement.revoke(); + }, + + populate: function (items) { + var self = this; + this.arrangement.populate(items); + } +}); +BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE"; +BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL"; +BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/** + * 月份下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.MonthCombo + * @extends BI.Trigger + */ +BI.MonthCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-combo", + behaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.MonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.month_trigger" + }); + + this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { + if (this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getValue()); + } else if (!this.getKey()) { + self.setValue(); + } + self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); + }); + this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.MonthTrigger.EVENT_START, function () { + self.combo.hideView(); + }); + this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + this.trigger.on(BI.MonthTrigger.EVENT_CHANGE, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + + this.popup = BI.createWidget({ + type: "bi.month_popup", + behaviors: o.behaviors + }); + this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + el: this.popup + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); + +BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.month_combo', BI.MonthCombo);/** + * 月份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.MonthPopup + * @extends BI.Trigger + */ +BI.MonthPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-popup", + behaviors: {} + }); + }, + + _init: function () { + BI.MonthPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + //纵向排列月 + var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; + var items = []; + items.push(month.slice(0, 2)); + items.push(month.slice(2, 4)); + items.push(month.slice(4, 6)); + items.push(month.slice(6, 8)); + items.push(month.slice(8, 10)); + items.push(month.slice(10, 12)); + items = BI.map(items, function (i, item) { + return BI.map(item, function (j, td) { + return { + type: "bi.text_item", + cls: "bi-list-item-active", + textAlign: "center", + whiteSpace: "nowrap", + once: false, + forceSelected: true, + height: 23, + width: 38, + value: td, + text: td + 1 + }; + }); + }); + + this.month = BI.createWidget({ + type: "bi.button_group", + element: this, + behaviors: o.behaviors, + items: BI.createItems(items, {}), + layouts: [BI.LogicFactory.createLogic("table", BI.extend({ + dynamic: true + }, { + columns: 2, + rows: 6, + columnSize: [1 / 2, 1 / 2], + rowSize: 25 + })), { + type: "bi.center_adapt", + vgap: 1, + hgap: 2 + }] + }); + + this.month.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MonthPopup.EVENT_CHANGE); + } + }) + }, + + getValue: function () { + return this.month.getValue()[0]; + }, + + setValue: function (v) { + this.month.setValue([v]); + } +}); +BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.month_popup", BI.MonthPopup);/** + * 月份trigger + * + * Created by GUY on 2015/8/21. + * @class BI.MonthTrigger + * @extends BI.Trigger + */ +BI.MonthTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 25, + errorText: BI.i18nText("BI-Month_Trigger_Error_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-month-trigger bi-border", + height: 25 + }); + }, + _init: function () { + BI.MonthTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: c.errorText + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.MonthTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.MonthTrigger.EVENT_CHANGE); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + self.editor.setTitle(value); + } + self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.MonthTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.MonthTrigger.EVENT_STOP); + }); + BI.createWidget({ + element: this, + type: 'bi.htape', + items: [ + { + el: this.editor + }, { + el: { + type: "bi.text_button", + text: BI.i18nText("BI-Multi_Date_Month"), + baseCls: "bi-trigger-month-text", + width: c.triggerWidth + }, + width: c.triggerWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + setValue: function (v) { + if(BI.isNotNull(v)){ + this.editor.setState(v + 1); + this.editor.setValue(v + 1); + this.editor.setTitle(v + 1); + return; + } + this.editor.setState(); + this.editor.setValue(); + this.editor.setTitle(); + }, + getKey: function () { + return this.editor.getValue() | 0; + }, + getValue: function () { + return this.editor.getValue() - 1; + } +}); +BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthTrigger.EVENT_START = "EVENT_START"; +BI.MonthTrigger.EVENT_STOP = "EVENT_STOP"; +BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.month_trigger", BI.MonthTrigger);/** + * @class BI.MultiLayerSelectTreeCombo + * @extends BI.Widget + */ +BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer_select_tree-combo", + isDefaultInit: false, + height: 30, + text: "", + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_select_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); +BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/** + * guy + * 二级树 + * @class BI.MultiLayerSelectLevelTree + * @extends BI.Select + */ +BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-select-level-tree", + isDefaultInit: false, + items: [], + itemsCreator: BI.emptyFn + }) + }, + + _init: function () { + BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _assertId: function (sNodes) { + BI.each(sNodes, function (i, node) { + node.id = node.id || BI.UUID(); + }); + }, + + //构造树结构, + initTree: function (nodes) { + var self = this, o = this.options; + this.empty(); + this._assertId(nodes); + this.tree = BI.createWidget({ + type: "bi.custom_tree", + element: this, + expander: { + type: "bi.select_tree_expander", + isDefaultInit: o.isDefaultInit, + el: {}, + popup: { + type: "bi.custom_tree" + } + }, + + items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), + itemsCreator: o.itemsCreator, + + el: { + type: "bi.button_tree", + chooseType: BI.Selection.Single, + layouts: [{ + type: "bi.vertical" + }] + } + }); + this.tree.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments); + } + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + setValue: function (v) { + this.tree.setValue(v); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + getAllLeaves: function () { + return this.tree.getAllLeaves(); + }, + + getNodeById: function (id) { + return this.tree.getNodeById(id); + }, + + getNodeByValue: function (id) { + return this.tree.getNodeByValue(id); + } +}); +BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/** + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSelectTreePopup + * @extends BI.Pane + */ + +BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-select-tree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + isDefaultInit: false, + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.multilayer_select_level_tree', + isDefaultInit: o.isDefaultInit, + items: o.items, + itemsCreator: o.itemsCreator + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active", + layer: 0,//第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_first_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active", + layer: 0,//第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_last_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active", + layer: 0,//第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_mid_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/** + * 多层级下拉单选树 + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSingleTreeCombo + * @extends BI.Widget + */ +BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-singletree-combo", + isDefaultInit: false, + height: 30, + text: "", + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_single_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); + +BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/** + * guy + * 二级树 + * @class BI.MultiLayerSingleLevelTree + * @extends BI.Single + */ +BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-single-level-tree", + isDefaultInit: false, + items: [], + itemsCreator: BI.emptyFn + }) + }, + + _init: function () { + BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_single_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_single_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _assertId: function (sNodes) { + BI.each(sNodes, function (i, node) { + node.id = node.id || BI.UUID(); + }); + }, + + //构造树结构, + initTree: function (nodes) { + var self = this, o = this.options; + this.empty(); + this._assertId(nodes); + this.tree = BI.createWidget({ + type: "bi.custom_tree", + element: this, + expander: { + isDefaultInit: o.isDefaultInit, + el: {}, + popup: { + type: "bi.custom_tree" + } + }, + + items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (items) { + callback(BI.Tree.transformToTreeFormat(items), 0) + }) + }, + + el: { + type: "bi.button_tree", + chooseType: BI.Selection.Single, + layouts: [{ + type: "bi.vertical" + }] + } + }); + this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v); + } + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + setValue: function (v) { + this.tree.setValue(v); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + getAllLeaves: function () { + return this.tree.getAllLeaves(); + }, + + getNodeById: function (id) { + return this.tree.getNodeById(id); + }, + + getNodeByValue: function (id) { + return this.tree.getNodeByValue(id); + } +}); +BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree); +/** + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSingleTreePopup + * @extends BI.Pane + */ + +BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-singletree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + isDefaultInit: false, + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.multilayer_single_level_tree', + isDefaultInit: o.isDefaultInit, + items: o.items, + itemsCreator: o.itemsCreator + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item", + layer: 0,//第几层级 + id: "", + pId: "", + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.first_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item", + layer: 0,//第几层级 + id: "", + pId: "", + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.last_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item", + layer: 0,//第几层级 + id: "", + pId: "", + open: false, + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.mid_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeFirstTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.first_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.item.doRedMark.apply(this.item, arguments); + }, + + unRedMark: function () { + this.item.unRedMark.apply(this.item, arguments); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeLastTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.last_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.item.doRedMark.apply(this.item, arguments); + }, + + unRedMark: function () { + this.item.unRedMark.apply(this.item, arguments); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeMidTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.mid_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {//本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + items: [items] + }) + }, + + doRedMark: function () { + this.item.doRedMark.apply(this.item, arguments); + }, + + unRedMark: function () { + this.item.unRedMark.apply(this.item, arguments); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/** + * + * @class BI.MultiSelectCheckPane + * @extends BI.Widget + */ +BI.MultiSelectCheckPane = BI.inherit(BI.Widget, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-check-pane bi-background", + items: [], + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + onClickContinueSelect: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectCheckPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.storeValue = {}; + this.display = BI.createWidget({ + type: 'bi.display_selected_list', + items: opts.items, + itemsCreator: function (op, callback) { + op = BI.extend(op || {}, { + selectedValues: self.storeValue.value + }); + if (self.storeValue.type === BI.Selection.Multi) { + callback({ + items: BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt + } + }) + }); + return; + } + opts.itemsCreator(op, callback); + } + }); + + this.continueSelect = BI.createWidget({ + type: 'bi.text_button', + text: BI.i18nText('BI-Continue_Select'), + cls: 'multi-select-check-selected bi-high-light' + }); + + this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { + opts.onClickContinueSelect(); + }); + + BI.createWidget({ + type: 'bi.vtape', + element: this, + items: [{ + height: this.constants.height, + el: { + type: 'bi.left', + cls: 'multi-select-continue-select', + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText('BI-Selected_Data') + }, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }, + { + el: this.continueSelect, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }] + } + }, { + height: 'fill', + el: this.display + }] + }); + }, + + setValue: function (v) { + this.storeValue = v || {}; + }, + + empty: function () { + this.display.empty(); + }, + + populate: function () { + this.display.populate.apply(this.display, arguments); + } +}); + +BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/** + * + * + * 查看已选弹出层的展示面板 + * @class BI.DisplaySelectedList + * @extends BI.Widget + */ +BI.DisplaySelectedList = BI.inherit(BI.Pane, { + + constants: { + height: 25, + lgap: 10 + }, + + _defaultConfig: function () { + return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-display-list", + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.DisplaySelectedList.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.hasNext = false; + + this.button_group = BI.createWidget({ + type: "bi.list_pane", + element: this, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + items: this._createItems(opts.items), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + layouts: [{ + type: "bi.vertical", + lgap: 10 + }] + }, + itemsCreator: function (options, callback) { + + opts.itemsCreator(options, function (ob) { + self.hasNext = !!ob.hasNext; + callback(self._createItems(ob.items)); + }) + }, + hasNext: function () { + return self.hasNext; + } + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: 'bi.icon_text_item', + cls: 'cursor-default check-font display-list-item bi-tips', + once: true, + invalid: true, + selected: true, + height: this.constants.height, + logic: { + dynamic: true + } + }); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + if (arguments.length === 0) { + this.button_group.populate(); + } else { + this.button_group.populate(this._createItems(items)); + } + } +}); + +BI.shortcut('bi.display_selected_list', BI.DisplaySelectedList);/** + * + * @class BI.MultiSelectCombo + * @extends BI.Single + */ +BI.MultiSelectCombo = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-combo', + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + height: 28 + }); + }, + + _init: function () { + BI.MultiSelectCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + self.trigger.getCounter().setButtonChecked(self.storeValue); + }; + this.storeValue = {}; + //标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + // adapter: this.popup, + masker: { + offset: { + left: 1, + top: 1, + right: 2, + bottom: 33 + } + }, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (res) { + if (op.times === 1 && BI.isNotNull(op.keywords)) { + //预防trigger内部把当前的storeValue改掉 + self.trigger.setValue(BI.deepClone(self.getValue())); + } + callback.apply(self, arguments); + }); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { + self._setStartValue(""); + this.getSearcher().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { + self._setStartValue(""); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { + if (this.getSearcher().hasMatched()) { + var keyword = this.getSearcher().getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self.combo.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.populate(); + self._setStartValue(""); + }) + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.combo.setValue(self.storeValue); + assertShowValue(); + self.combo.populate(); + self._setStartValue(""); + } else { + self.combo.setValue(self.storeValue); + assertShowValue(); + } + }); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + }); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + this.getCounter().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: 'bi.multi_select_popup_view', + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + onLoaded: function () { + BI.nextTick(function () { + self.combo.adjustWidth(); + self.combo.adjustHeight(); + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + this.setValue(self.storeValue); + BI.nextTick(function () { + self.populate(); + }); + }); + //当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + //important:关闭弹出时又可能没有退出编辑状态 + self.trigger.stopEditing(); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + } + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button bi-border-left" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }) + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, + keywords: keywords + }, function (ob) { + var values = BI.pluck(ob.items, "value"); + digest(values); + }); + + function digest(items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, + keywords: [this.trigger.getKey()] + }, function (ob) { + var items = BI.pluck(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }) + }, + + _adjust: function (callback) { + var self = this, o = this.options; + if (!this._count) { + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH + }, function (res) { + self._count = res.count; + adjust(); + callback(); + }); + } else { + adjust(); + callback(); + } + function adjust() { + if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.Multi, + value: [] + } + } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.All, + value: [] + } + } + if (self.wants2Quit === true) { + self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.popup.setStartValue(value); + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.combo.setValue(this.storeValue); + }, + + getValue: function () { + return this.storeValue; + }, + + populate: function () { + this._count = null; + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.extend(BI.MultiSelectCombo, { + REQ_GET_DATA_LENGTH: 0, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/** + * 多选加载数据面板 + * Created by guy on 15/11/2. + * @class BI.MultiSelectLoader + * @extends Widget + */ +BI.MultiSelectLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-loader', + logic: { + dynamic: true + }, + el: { + height: 400 + }, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + + this.button_group = BI.createWidget({ + type: "bi.select_list", + element: this, + logic: opts.logic, + el: BI.extend({ + onLoaded: opts.onLoaded, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, opts.el), + itemsCreator: function (op, callback) { + var startValue = self._startValue; + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi + ? self.storeValue.value.concat(startValue) : self.storeValue.value + })); + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + } + }); + if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) { + var txt = opts.valueFormatter(startValue) || startValue; + json.unshift({ + text: txt, + value: startValue, + title: txt, + selected: true + }) + } + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { + BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); + self.setValue(self.storeValue); + } + (op.times === 1) && self._scrollToTop(); + }); + }, + hasNext: function () { + return hasNext; + } + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: this.options.logic, + height: 25, + selected: this.isAllSelected() + }) + }, + + _scrollToTop: function () { + var self = this; + BI.delay(function () { + self.button_group.element.scrollTop(0); + }, 30); + }, + + isAllSelected: function () { + return this.button_group.isAllSelected(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + setStartValue: function (v) { + this._startValue = v; + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.button_group.setValue(this.storeValue); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/** + * 带加载的多选下拉面板 + * @class BI.MultiSelectPopupView + * @extends Widget + */ +BI.MultiSelectPopupView = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-popup-view', + maxWidth: 'auto', + minWidth: 135, + maxHeight: 400, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectPopupView.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + + this.loader = BI.createWidget({ + type: "bi.multi_select_loader", + itemsCreator: opts.itemsCreator, + valueFormatter: opts.valueFormatter, + onLoaded: opts.onLoaded + }); + + this.popupView = BI.createWidget({ + type: "bi.multi_popup_view", + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + element: this, + buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')], + el: this.loader + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE); + }); + this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { + switch (index) { + case 0: + self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR); + break; + case 1: + self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM); + break; + } + }); + }, + + isAllSelected: function () { + return this.loader.isAllSelected(); + }, + + setStartValue: function (v) { + this.loader.setStartValue(v); + }, + + setValue: function (v) { + this.popupView.setValue(v); + }, + + getValue: function () { + return this.popupView.getValue(); + }, + + populate: function (items) { + this.popupView.populate.apply(this.popupView, arguments); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; + + +BI.shortcut('bi.multi_select_popup_view', BI.MultiSelectPopupView);/** + * + * 复选下拉框 + * @class BI.MultiSelectTrigger + * @extends BI.Trigger + */ + +BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { + + constants: { + height: 14, + rgap: 4, + lgap: 4 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-trigger bi-border", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + searcher: {}, + switcher: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + if (o.height) { + this.setHeight(o.height - 2); + } + + this.searcher = BI.createWidget(o.searcher, { + type: "bi.multi_select_searcher", + height: o.height, + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + popup: {}, + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_START); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments); + }); + this.numberCounter = BI.createWidget(o.switcher, { + type: 'bi.multi_select_check_selected_switcher', + valueFormatter: o.valueFormatter, + itemsCreator: o.itemsCreator, + adapter: o.adapter, + masker: o.masker + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK); + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW); + }); + + var wrapNumberCounter = BI.createWidget({ + type: 'bi.right_vertical_adapt', + hgap: 4, + items: [{ + el: this.numberCounter + }] + }); + + var wrapper = BI.createWidget({ + type: 'bi.htape', + element: this, + items: [ + { + el: this.searcher, + width: 'fill' + }, { + el: wrapNumberCounter, + width: 0 + }, { + el: BI.createWidget(), + width: 30 + }] + }); + + this.numberCounter.on(BI.Events.VIEW, function (b) { + BI.nextTick(function () {//自动调整宽度 + wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0); + wrapper.resize(); + }); + }); + + this.element.click(function (e) { + if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { + self.numberCounter.hideView(); + } + }); + }, + + getCounter: function () { + return this.numberCounter; + }, + + getSearcher: function () { + return this.searcher; + }, + + stopEditing: function () { + this.searcher.stopSearch(); + this.numberCounter.hideView(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + this.numberCounter.setAdapter(adapter); + }, + + setValue: function (ob) { + this.searcher.setValue(ob); + this.numberCounter.setValue(ob); + }, + + getKey: function () { + return this.searcher.getKey(); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); + +BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; +BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectTrigger.EVENT_START = "EVENT_START"; +BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP"; +BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; + +BI.shortcut('bi.multi_select_trigger', BI.MultiSelectTrigger);/** + * 多选加载数据搜索loader面板 + * Created by guy on 15/11/4. + * @class BI.MultiSelectSearchLoader + * @extends Widget + */ +BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-search-loader', + itemsCreator: BI.emptyFn, + keywordGetter: BI.emptyFn, + valueFormatter: BI.emptyFn, + }); + }, + + _init: function () { + BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + + this.button_group = BI.createWidget({ + type: "bi.select_list", + element: this, + logic: { + dynamic: false + }, + el: { + tipText: BI.i18nText("BI-No_Select"), + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, + itemsCreator: function (op, callback) { + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: self.storeValue.value + })); + opts.itemsCreator(op, function (ob) { + var keyword = ob.keyword = opts.keywordGetter(); + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = self._filterValues(self.storeValue); + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), keyword); + if (op.times === 1 && self.storeValue) { + self.setValue(self.storeValue); + } + }); + }, + hasNext: function () { + return hasNext; + } + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: { + dynamic: false + }, + height: 25, + selected: this.isAllSelected() + }) + }, + + isAllSelected: function () { + return this.button_group.isAllSelected(); + }, + + _filterValues: function (src) { + var o = this.options; + var keyword = o.keywordGetter(); + var values = BI.deepClone(src.value) || []; + var newValues = BI.map(values, function (i, v) { + return { + text: o.valueFormatter(v) || v, + value: v + }; + }); + if (BI.isKey(keyword)) { + var search = BI.Func.getSearchResult(newValues, keyword); + values = search.matched.concat(search.finded); + } + return BI.map(values, function (i, v) { + return { + text: v.text, + title: v.text, + value: v.value, + selected: src.type === BI.Selection.All + } + }) + }, + + setValue: function (v) { + //暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 + this.storeValue = BI.deepClone(v); + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_select_search_loader', BI.MultiSelectSearchLoader);/** + * + * 在搜索框中输入文本弹出的面板 + * @class BI.MultiSelectSearchPane + * @extends Widget + */ + +BI.MultiSelectSearchPane = BI.inherit(BI.Widget, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-search-pane bi-card", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + keywordGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectSearchPane.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.tooltipClick = BI.createWidget({ + type: "bi.label", + invisible: true, + text: BI.i18nText('BI-Click_Blank_To_Select'), + cls: 'multi-select-toolbar', + height: this.constants.height + }); + + this.loader = BI.createWidget({ + type: "bi.multi_select_search_loader", + keywordGetter: o.keywordGetter, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator.apply(self, [op, function (res) { + callback(res); + self.setKeyword(o.keywordGetter()); + }]); + } + }); + this.loader.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.resizer = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.tooltipClick, + height: 0 + }, { + el: this.loader + }] + }); + this.tooltipClick.setVisible(false); + }, + + setKeyword: function (keyword) { + var btn; + var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); + if (isVisible !== this.tooltipClick.isVisible()) { + this.tooltipClick.setVisible(isVisible); + this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); + this.resizer.resize(); + } + }, + + isAllSelected: function () { + return this.loader.isAllSelected(); + }, + + hasMatched: function () { + return this.tooltipClick.isVisible(); + }, + + setValue: function (v) { + this.loader.setValue(v); + }, + + getValue: function () { + return this.loader.getValue(); + }, + + empty: function () { + this.loader.empty(); + }, + + populate: function (items) { + this.loader.populate.apply(this.loader, arguments); + } +}); + +BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/** + * 查看已选按钮 + * Created by guy on 15/11/3. + * @class BI.MultiSelectCheckSelectedButton + * @extends BI.Single + */ +BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-check-selected-button bi-high-light', + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments); + var self = this; + this.numberCounter = BI.createWidget({ + type: 'bi.text_button', + element: this, + hgap: 4, + text: "0", + textAlign: 'center', + textHeight: 15 + }); + this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments); + }); + + this.numberCounter.element.hover(function () { + self.numberCounter.setTag(self.numberCounter.getText()); + self.numberCounter.setText(self._const.checkSelected); + }, function () { + self.numberCounter.setText(self.numberCounter.getTag()); + }); + this.setVisible(false); + }, + + setValue: function (ob) { + var self = this, o = this.options; + ob || (ob = {}); + ob.type || (ob.type = BI.Selection.Multi); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH + }, function (res) { + var length = res.count - ob.value.length; + BI.nextTick(function(){ + self.numberCounter.setText(length); + self.setVisible(length > 0); + }); + }); + return; + } + BI.nextTick(function(){ + self.numberCounter.setText(ob.value.length); + self.setVisible(ob.value.length > 0); + }) + }, + + getValue: function () { + + } +}); + +BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_select_check_selected_button', BI.MultiSelectCheckSelectedButton);/** + * 多选输入框 + * Created by guy on 15/11/3. + * @class BI.MultiSelectEditor + * @extends Widget + */ +BI.MultiSelectEditor = BI.inherit(BI.Widget, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-editor', + el: {} + }); + }, + + _init: function () { + BI.MultiSelectEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: 'bi.state_editor', + element: this, + height: o.height, + watermark: BI.i18nText('BI-Basic_Search'), + allowBlank: true + }); + + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.editor.on(BI.StateEditor.EVENT_PAUSE, function () { + self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE); + }); + this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () { + + }); + }, + + focus: function () { + this.editor.focus(); + }, + + blur: function () { + this.editor.blur(); + }, + + setState: function (state) { + this.editor.setState(state); + }, + + setValue: function (v) { + this.editor.setValue(v); + }, + + getValue: function () { + var v = this.editor.getState(); + if (BI.isArray(v) && v.length > 0) { + return v[v.length - 1]; + } else { + return ""; + } + }, + + getKeywords: function () { + var val = this.editor.getLastValidValue(); + var keywords = val.match(/[\S]+/g); + if (BI.isEndWithBlank(val)) { + return keywords.concat([' ']); + } + return keywords; + }, + + populate: function (items) { + + } +}); +BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE"; +BI.shortcut('bi.multi_select_editor', BI.MultiSelectEditor);/** + * searcher + * Created by guy on 15/11/3. + * @class BI.MultiSelectSearcher + * @extends Widget + */ +BI.MultiSelectSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-searcher', + itemsCreator: BI.emptyFn, + el: {}, + popup: {}, + valueFormatter: BI.emptyFn, + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: 'bi.multi_select_editor', + height: o.height + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + height: o.height, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.multi_select_search_pane", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.editor.getValue(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); + } + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments); + }); + this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { + var keywords = this.getKeywords(); + self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords); + }); + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + setState: function (ob) { + var o = this.options; + ob || (ob = {}); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + if (BI.size(ob.assist) === 1) { + this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + "")); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); + } + } else { + if (BI.size(ob.value) === 1) { + this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + "")); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); + } + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectSearcher.EVENT_START = "EVENT_START"; +BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP"; +BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.shortcut('bi.multi_select_searcher', BI.MultiSelectSearcher);/** + * 查看已选switcher + * Created by guy on 15/11/3. + * @class BI.MultiSelectCheckSelectedSwitcher + * @extends Widget + */ +BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-check-selected-switcher', + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + el: {}, + popup: {}, + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.button = BI.createWidget(o.el, { + type: "bi.multi_select_check_selected_button", + itemsCreator: o.itemsCreator + }); + this.button.on(BI.Events.VIEW, function () { + self.fireEvent(BI.Events.VIEW, arguments); + }); + this.switcher = BI.createWidget({ + type: "bi.switcher", + toggle: false, + element: this, + el: this.button, + popup: BI.extend({ + type: "bi.multi_select_check_pane", + valueFormatter: o.valueFormatter, + itemsCreator: o.itemsCreator, + onClickContinueSelect: function () { + self.switcher.hideView(); + } + }, o.popup), + adapter: o.adapter, + masker: o.masker + }); + this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE); + }); + this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW); + }); + this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () { + var me = this; + BI.nextTick(function () { + me.populate(); + }); + }); + + this.switcher.element.click(function (e) { + e.stopPropagation(); + }); + }, + + adjustView: function () { + this.switcher.adjustView(); + }, + + hideView: function () { + this.switcher.empty(); + this.switcher.hideView(); + }, + + setAdapter: function (adapter) { + this.switcher.setAdapter(adapter); + }, + + setValue: function (v) { + this.switcher.setValue(v); + }, + + setButtonChecked: function (v) { + this.button.setValue(v) + }, + + getValue: function () { + + }, + + populate: function (items) { + this.switcher.populate.apply(this.switcher, arguments); + } +}); + +BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; +BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** + * Created by zcf_1 on 2017/5/2. + */ +BI.MultiSelectList = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-list', + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn + }) + }, + _init: function () { + BI.MultiSelectList.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + this.storeValue = {}; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + // self.trigger.setValue(self.storeValue); + }; + + this.adapter = BI.createWidget({ + type: "bi.multi_select_loader", + cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + // onLoaded: o.onLoaded, + el: { + height: "" + } + }); + this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }); + }); + + this.searcherPane = BI.createWidget({ + type: "bi.multi_select_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.trigger.getKeyword(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self._setStartValue(""); + this.setValue(BI.deepClone(self.storeValue)); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(""); + self.adapter.setValue(self.storeValue); + //需要刷新回到初始界面,否则搜索的结果不能放在最前面 + self.adapter.populate(); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + if (this.hasMatched()) { + var keyword = this.getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self._setStartValue(""); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }) + } else { + self._showAdapter(); + } + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeyword(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + } else { + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () {//安徽省 北京 + assertShowValue(); + }); + } + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.trigger, + height: 30 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }) + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + if (!this._allData) { + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_ALL_DATA + }, function (ob) { + self._allData = BI.pluck(ob.items, "value"); + digest(self._allData); + }) + } else { + digest(this._allData) + } + + function digest(items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_ALL_DATA, + keyword: self.trigger.getKeyword() + }, function (ob) { + var items = BI.pluck(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }) + }, + + _adjust: function (callback) { + var self = this, o = this.options; + if (!this._count) { + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_DATA_LENGTH + }, function (res) { + self._count = res.count; + adjust(); + callback(); + }); + } else { + adjust(); + callback(); + } + function adjust() { + if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.Multi, + value: [] + } + } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.All, + value: [] + } + } + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.adapter.setStartValue(value); + }, + + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, + + resize: function () { + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); + }, + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.adapter.setValue(this.storeValue); + this.trigger.setValue(this.storeValue); + }, + + getValue: function () { + return this.storeValue; + }, + + populate: function () { + this._count = null; + this._allData = null; + this.adapter.populate.apply(this.adapter, arguments); + this.trigger.populate.apply(this.trigger, arguments); + } +}); + +BI.extend(BI.MultiSelectList, { + REQ_GET_DATA_LENGTH: 0, + REQ_GET_ALL_DATA: -1 +}); + +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 + }) + }, + + _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.searcher.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.setSelectedValue(self.storeValue.value); + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + }); + + //搜索中的时候用的是parttree,同adapter中的synctree不一样 + this.searcherPane = BI.createWidget({ + type: "bi.multi_tree_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + keywordGetter: function () { + return self.searcher.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.searcher.getKeyword(); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.searcher.getKeyword() + }); + }, + adapter: this.adapter, + popup: this.searcherPane, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + // self.storeValue = {value: self.adapter.getValue()}; + // self.searcherPane.setSelectedValue(self.storeValue.value); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + // self.storeValue = {value: self.searcherPane.getValue()}; + // self.adapter.setSelectedValue(self.storeValue.value); + BI.nextTick(function () { + self.adapter.populate(); + }); + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + if (self.searcher.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.setSelectedValue(self.storeValue.value); + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + self._showAdapter(); + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.searcher, + height: 30 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + 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 () { + + }, + + setSelectedValue: function (v) { + this.storeValue.value = v || {}; + this.adapter.setSelectedValue(v); + this.searcherPane.setSelectedValue(v); + this.searcher.setValue({ + value: v || {} + }); + }, + + setValue: function (v) { + this.adapter.setValue(v); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + updateValue: function (v) { + this.adapter.updateValue(v); + }, + + getValue: function () { + return this.storeValue.value; + }, + + populate: function () { + this.searcher.populate.apply(this.searcher, 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", + 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); + }, + + setSelectedValue: function (v) { + v || (v = {}); + this.popup.setSelectedValue(v); + }, + + updateValue: function (v) { + this.popup.updateValue(v); + this.popup.refresh(); + }, + + 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 + */ +BI.MultiTreeCheckPane = BI.inherit(BI.Pane, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-check-pane bi-background", + onClickContinueSelect: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeCheckPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.selectedValues = {}; + + var continueSelect = BI.createWidget({ + type: 'bi.text_button', + text: BI.i18nText('BI-Continue_Select'), + cls: 'multi-tree-check-selected' + }); + continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { + opts.onClickContinueSelect(); + BI.nextTick(function () { + self.empty(); + }); + }); + + var backToPopup = BI.createWidget({ + type: 'bi.left', + cls: 'multi-tree-continue-select', + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText('BI-Selected_Data') + }, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }, + { + el: continueSelect, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }] + }); + + this.display = BI.createWidget({ + type: "bi.display_tree", + cls: "bi-multi-tree-display", + itemsCreator: function (op, callback) { + op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA; + opts.itemsCreator(op, callback); + } + }); + + this.display.on(BI.Events.AFTERINIT, function () { + self.fireEvent(BI.Events.AFTERINIT); + }); + + this.display.on(BI.TreeView.EVENT_INIT, function () { + backToPopup.setVisible(false); + }); + + this.display.on(BI.TreeView.EVENT_AFTERINIT, function () { + backToPopup.setVisible(true); + }); + + BI.createWidget({ + type: 'bi.vtape', + element: this, + items: [{ + height: this.constants.height, + el: backToPopup + }, { + height: 'fill', + el: this.display + }] + }); + + }, + + empty: function () { + this.display.empty(); + }, + + populate: function (configs) { + this.display.stroke(configs); + }, + + setValue: function (v) { + v || (v = {}); + this.display.setSelectedValue(v.value); + }, + + getValue: function () { + + } +}); + +BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK"; + + +BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/** + * + * @class BI.MultiTreeCombo + * @extends BI.Single + */ + +BI.MultiTreeCombo = BI.inherit(BI.Single, { + + constants: { + offset: { + top: 1, + left: 1, + right: 2, + bottom: 33 + } + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-combo', + itemsCreator: BI.emptyFn, + height: 25 + }); + }, + + _init: function () { + BI.MultiTreeCombo.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + var isInit = false; + var want2showCounter = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + // adapter: this.popup, + masker: { + offset: this.constants.offset + }, + searcher: { + type: "bi.multi_tree_searcher", + itemsCreator: o.itemsCreator + }, + switcher: { + el: { + type: "bi.multi_tree_check_selected_button" + }, + popup: { + type: "bi.multi_tree_check_pane", + itemsCreator: o.itemsCreator + } + } + + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: 'bi.multi_tree_popup_view', + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiTreePopup.EVENT_AFTERINIT, + action: function () { + self.trigger.getCounter().adjustView(); + isInit = true; + if (want2showCounter === true) { + showCounter(); + } + } + }, { + eventName: BI.MultiTreePopup.EVENT_CHANGE, + action: function () { + change = true; + var val = { + type: BI.Selection.Multi, + value: this.hasChecked() ? {1: 1} : {} + }; + self.trigger.getSearcher().setState(val); + self.trigger.getCounter().setButtonChecked(val); + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, + action: function () { + self.combo.hideView(); + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, + action: function () { + clear = true; + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: o.itemsCreator, + onLoaded: function () { + BI.nextTick(function () { + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.storeValue = {value: {}}; + var change = false; + var clear = false; //标识当前是否点击了清空 + + var isSearching = function () { + return self.trigger.getSearcher().isSearching(); + }; + + var isPopupView = function () { + return self.combo.isViewVisible(); + }; + + this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { + self.storeValue = {value: self.combo.getValue()}; + this.setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { + self.storeValue = {value: this.getValue()}; + self.combo.setValue(self.storeValue); + BI.nextTick(function () { + if (isPopupView()) { + self.combo.populate(); + } + }); + }); + function showCounter() { + if (isSearching()) { + self.storeValue = {value: self.trigger.getValue()}; + } else if (isPopupView()) { + self.storeValue = {value: self.combo.getValue()}; + } + self.trigger.setValue(self.storeValue); + } + + this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + if (want2showCounter === false) { + want2showCounter = true; + } + if (isInit === true) { + want2showCounter = null; + showCounter(); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () { + var val = { + type: BI.Selection.Multi, + value: this.getSearcher().hasChecked() ? {1: 1} : {} + }; + this.getSearcher().setState(val); + this.getCounter().setButtonChecked(val); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + if (isSearching()) { + return; + } + if (change === true) { + self.storeValue = {value: self.combo.getValue()}; + change = false; + } + self.combo.setValue(self.storeValue); + self.populate(); + + }); + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + if (isSearching()) { + self.trigger.stopEditing(); + self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); + }else{ + if (isPopupView()) { + self.trigger.stopEditing(); + self.storeValue = {value: self.combo.getValue()}; + if (clear === true) { + self.storeValue = {value: {}}; + } + self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); + } + } + clear = false; + change = false; + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button bi-border-left" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }) + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + setValue: function (v) { + this.storeValue.value = v || {}; + this.combo.setValue({ + value: v || {} + }); + }, + + getValue: function () { + return this.storeValue.value; + }, + + populate: function () { + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM"; + +BI.shortcut('bi.multi_tree_combo', BI.MultiTreeCombo);/** + * 带加载的多选下拉面板 + * @class BI.MultiTreePopup + * @extends BI.Pane + */ +BI.MultiTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-popup', + maxWidth: 'auto', + minWidth: 100, + maxHeight: 400, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreePopup.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.selectedValues = {}; + + this.tree = BI.createWidget({ + type: "bi.async_tree", + height: 400, + cls:"popup-view-tree", + itemsCreator: opts.itemsCreator, + onLoaded: opts.onLoaded + }); + + this.popupView = BI.createWidget({ + type: "bi.multi_popup_view", + element: this, + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + buttons: [BI.i18nText('BI-Basic_Clears'), BI.i18nText('BI-Basic_Sure')], + el: this.tree + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { + switch (index) { + case 0: + self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR); + break; + case 1: + self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM); + break; + } + }); + + this.tree.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE); + }); + + this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () { + self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT); + }); + + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v || (v = {}); + this.tree.setSelectedValue(v.value); + }, + + populate: function (config) { + this.tree.stroke(config); + }, + + hasChecked: function () { + return this.tree.hasChecked(); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; +BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT"; + + +BI.shortcut('bi.multi_tree_popup_view', BI.MultiTreePopup);/** + * + * 在搜索框中输入文本弹出的面板 + * @class BI.MultiTreeSearchPane + * @extends BI.Pane + */ + +BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-search-pane bi-card", + itemsCreator: BI.emptyFn, + keywordGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeSearchPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.partTree = BI.createWidget({ + type: "bi.part_tree", + element: this, + tipText: BI.i18nText("BI-No_Select"), + itemsCreator: function (op, callback) { + op.keyword = opts.keywordGetter(); + opts.itemsCreator(op, callback); + } + }); + + this.partTree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.partTree.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); + }); + }, + + hasChecked: function () { + return this.partTree.hasChecked(); + }, + + setValue: function (v) { + this.setSelectedValue(v.value); + }, + + setSelectedValue: function (v) { + v || (v = {}); + this.partTree.setSelectedValue(v); + }, + + getValue: function () { + return this.partTree.getValue(); + }, + + empty: function () { + this.partTree.empty(); + }, + + populate: function (op) { + this.partTree.stroke.apply(this.partTree, arguments); + } +}); + +BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; + +BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/** + * 查看已选按钮 + * Created by guy on 15/11/3. + * @class BI.MultiTreeCheckSelectedButton + * @extends BI.Single + */ +BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-check-selected-button', + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments); + var self = this; + this.indicator = BI.createWidget({ + type: 'bi.icon_button', + cls: 'check-font trigger-check-selected', + width: 15, + height: 15, + stopPropagation: true + }); + + this.checkSelected = BI.createWidget({ + type: 'bi.text_button', + cls: "trigger-check-selected", + invisible: true, + hgap: 4, + text: this._const.checkSelected, + textAlign: 'center', + textHeight: 15 + }); + this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + type: "bi.horizontal", + element: this, + items: [this.indicator, this.checkSelected] + }) + + this.element.hover(function () { + self.indicator.setVisible(false); + self.checkSelected.setVisible(true); + }, function () { + self.indicator.setVisible(true); + self.checkSelected.setVisible(false); + }); + this.setVisible(false); + }, + + setValue: function (v) { + v || (v = {}); + this.setVisible(BI.size(v.value) > 0); + } +}); + +BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_tree_check_selected_button', BI.MultiTreeCheckSelectedButton);/** + * searcher + * Created by guy on 15/11/3. + * @class BI.MultiTreeSearcher + * @extends Widget + */ +BI.MultiTreeSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-searcher', + itemsCreator: BI.emptyFn, + popup: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiTreeSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: 'bi.multi_select_editor', + height: o.height, + el: { + type: "bi.simple_state_editor", + height: o.height + } + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.editor.getValue() + }); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.multi_tree_search_pane", + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.editor.getValue(); + o.itemsCreator(op, callback); + } + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments); + }); + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setState: function (ob) { + ob || (ob = {}); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +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);//小于号的值为:0,小于等于号的值为:1 +//closeMIn:最小值的符号,closeMax:最大值的符号 +/** + * Created by roy on 15/9/17. + * + */ +BI.NumericalInterval = BI.inherit(BI.Single, { + constants: { + typeError: "typeBubble", + numberError: "numberBubble", + signalError: "signalBubble", + editorWidth: 114, + columns: 5, + width: 30, + rows: 1, + numberErrorCls: "number-error", + border: 1, + less: 0, + less_equal: 1, + numTip: "" + }, + _defaultConfig: function () { + var conf = BI.NumericalInterval.superclass._defaultConfig.apply(this, arguments) + return BI.extend(conf, { + extraCls: "bi-numerical-interval", + height: 25, + validation: "valid" + }) + }, + _init: function () { + var self = this, c = this.constants, o = this.options; + BI.NumericalInterval.superclass._init.apply(this, arguments) + this.smallEditor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.min, + level: "warning", + tipType: "warning", + quitChecker: function () { + return false; + }, + validationChecker: function (v) { + if (!BI.isNumeric(v)) { + self.smallEditorBubbleType = c.typeError; + return false; + } + return true; + }, + cls: "numerical-interval-small-editor bi-border-top bi-border-bottom bi-border-left" + }); + + this.smallTip = BI.createWidget({ + type: "bi.label", + text: o.numTip, + height: o.height - 2, + invisible: true + }); + BI.createWidget({ + type: "bi.absolute", + element: this.smallEditor.element, + items: [{ + el: this.smallTip, + top: 0, + right: 5 + }] + }); + + this.bigEditor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.max, + level: "warning", + tipType: "warning", + quitChecker: function () { + return false; + }, + validationChecker: function (v) { + if (!BI.isNumeric(v)) { + self.bigEditorBubbleType = c.typeError; + return false; + } + return true; + }, + cls: "numerical-interval-big-editor bi-border-top bi-border-bottom bi-border-right" + }); + + this.bigTip = BI.createWidget({ + type: "bi.label", + text: o.numTip, + height: o.height - 2, + invisible: true + }); + BI.createWidget({ + type: "bi.absolute", + element: this.bigEditor.element, + items: [{ + el: this.bigTip, + top: 0, + right: 5 + }] + }); + + //this.smallCombo = BI.createWidget({ + // type: "bi.numerical_interval_combo", + // cls: "numerical-interval-small-combo", + // height: o.height, + // value: o.closemin ? 1 : 0, + // offsetStyle: "left" + //}); + // + //this.bigCombo = BI.createWidget({ + // type: "bi.numerical_interval_combo", + // cls: "numerical-interval-big-combo", + // height: o.height, + // value: o.closemax ? 1 : 0, + // offsetStyle: "left" + //}); + this.smallCombo = BI.createWidget({ + type: "bi.icon_combo", + cls: "numerical-interval-small-combo bi-border", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconClass: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconClass: "less-equal-font" + }] + }); + if (o.closemin === true) { + this.smallCombo.setValue(1); + } else { + this.smallCombo.setValue(0); + } + this.bigCombo = BI.createWidget({ + type: "bi.icon_combo", + cls: "numerical-interval-big-combo bi-border", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconClass: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconClass: "less-equal-font" + }] + }); + if (o.closemax === true) { + this.bigCombo.setValue(1); + } else { + this.bigCombo.setValue(0); + } + this.label = BI.createWidget({ + type: "bi.label", + text: BI.i18nText("BI-Basic_Value"), + textHeight: o.height - c.border * 2, + width: c.width - c.border * 2, + height: o.height - c.border * 2, + level: "warning", + tipType: "warning" + }); + this.left = BI.createWidget({ + type: "bi.htape", + items: [{ + el: self.smallEditor + }, { + el: self.smallCombo, + width: c.width - c.border * 2 + }] + + }); + this.right = BI.createWidget({ + type: "bi.htape", + items: [{ + el: self.bigCombo, + width: c.width - c.border * 2 + }, { + el: self.bigEditor + }] + }); + + + BI.createWidget({ + element: self, + type: "bi.center", + hgap: 15, + height: o.height, + items: [ + { + type: "bi.absolute", + items: [{ + el: self.left, + left: -15, + right: 0, + top: 0, + bottom: 0 + }] + }, { + type: "bi.absolute", + items: [{ + el: self.right, + left: 0, + right: -15, + top: 0, + bottom: 0 + }] + } + ] + }); + + BI.createWidget({ + element: self, + type: "bi.horizontal_auto", + items: [ + self.label + ] + }); + + + self._setValidEvent(self.bigEditor, c.bigEditor); + self._setValidEvent(self.smallEditor, c.smallEditor); + self._setErrorEvent(self.bigEditor, c.bigEditor); + self._setErrorEvent(self.smallEditor, c.smallEditor); + self._setBlurEvent(self.bigEditor); + self._setBlurEvent(self.smallEditor); + self._setFocusEvent(self.bigEditor); + self._setFocusEvent(self.smallEditor); + self._setComboValueChangedEvent(self.bigCombo); + self._setComboValueChangedEvent(self.smallCombo); + self._setEditorValueChangedEvent(self.bigEditor); + self._setEditorValueChangedEvent(self.smallEditor); + }, + + _checkValidation: function () { + var self = this, c = this.constants, o = this.options; + self._setTitle(""); + BI.Bubbles.hide(c.typeError); + BI.Bubbles.hide(c.numberError); + BI.Bubbles.hide(c.signalError); + if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) { + self.element.removeClass("number-error"); + o.validation = "invalid"; + return c.typeError; + } else { + if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } else { + var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()), + bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue(); + if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) { + if (smallValue > bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.numberError; + } else { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } + } else { + if (smallValue > bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.numberError; + } else if (smallValue === bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.signalError; + } else { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } + } + } + + } + }, + + _setTitle: function (v) { + var self = this; + self.bigEditor.setTitle(v); + self.smallEditor.setTitle(v); + self.label.setTitle(v); + }, + + _setFocusEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_FOCUS, function () { + self._setTitle(""); + switch (self._checkValidation()) { + case c.typeError: + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "center" + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + break; + default : + return + } + + }) + }, + _setBlurEvent: function (w) { + var c = this.constants, self = this; + w.on(BI.Editor.EVENT_BLUR, function () { + BI.Bubbles.hide(c.typeError); + BI.Bubbles.hide(c.numberError); + BI.Bubbles.hide(c.signalError); + switch (self._checkValidation()) { + case c.typeError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); + break; + case c.numberError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); + break; + case c.signalError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); + break; + default: + self._setTitle(""); + } + }) + }, + + _setErrorEvent: function (w) { + var c = this.constants, self = this + w.on(BI.Editor.EVENT_ERROR, function () { + self._checkValidation(); + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + }) + }, + + + _setValidEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_VALID, function () { + switch (self._checkValidation()) { + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + default: + self.fireEvent(BI.NumericalInterval.EVENT_VALID); + } + }) + }, + + + _setEditorValueChangedEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_CHANGE, function () { + switch (self._checkValidation()) { + case c.typeError: + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "center" + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + break; + default : + break; + } + self.fireEvent(BI.NumericalInterval.EVENT_CHANGE); + }); + }, + + _setComboValueChangedEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.IconCombo.EVENT_CHANGE, function () { + switch (self._checkValidation()) { + case c.typeError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + case c.numberError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + case c.signalError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); + self.fireEvent(BI.NumericalInterval.EVENT_ERROR); + break; + default : + self.fireEvent(BI.NumericalInterval.EVENT_CHANGE); + self.fireEvent(BI.NumericalInterval.EVENT_VALID); + } + }) + }, + + isStateValid: function () { + return this.options.validation === "valid"; + }, + + setMinEnable: function (b) { + this.smallEditor.setEnable(b); + }, + + setCloseMinEnable: function (b) { + this.smallCombo.setEnable(b); + }, + + setMaxEnable: function (b) { + this.bigEditor.setEnable(b); + }, + + setCloseMaxEnable: function (b) { + this.bigCombo.setEnable(b); + }, + + showNumTip: function () { + this.smallTip.setVisible(true); + this.bigTip.setVisible(true); + }, + + hideNumTip: function () { + this.smallTip.setVisible(false); + this.bigTip.setVisible(false); + }, + + setNumTip: function(numTip) { + this.smallTip.setText(numTip); + this.bigTip.setText(numTip); + }, + + getNumTip: function() { + return this.smallTip.getText(); + }, + + setValue: function (data) { + data = data || {}; + var self = this, combo_value; + if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) { + self.smallEditor.setValue(data.min); + } + + if (!BI.isNotNull(data.min)) { + self.smallEditor.setValue(""); + } + + if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) { + self.bigEditor.setValue(data.max); + } + + if (!BI.isNotNull(data.max)) { + self.bigEditor.setValue(""); + } + + if (!BI.isNull(data.closemin)) { + if (data.closemin === true) { + combo_value = 1 + } else { + combo_value = 0 + } + self.smallCombo.setValue(combo_value); + } + + if (!BI.isNull(data.closemax)) { + if (data.closemax === true) { + combo_value = 1 + } else { + combo_value = 0 + } + self.bigCombo.setValue(combo_value); + } + }, + + + getValue: function () { + var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue(); + value.min = self.smallEditor.getValue(); + value.max = self.bigEditor.getValue(); + if (minComboValue[0] === 0) { + value.closemin = false + } else { + value.closemin = true + } + + if (maxComboValue[0] === 0) { + value.closemax = false + } else { + value.closemax = true + } + return value; + } +}); +BI.NumericalInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.NumericalInterval.EVENT_VALID = "EVENT_VALID"; +BI.NumericalInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.shortcut("bi.numerical_interval", BI.NumericalInterval);/** + * + * 表格 + * + * Created by GUY on 2015/9/22. + * @class BI.PageTableCell + * @extends BI.Single + */ +BI.PageTableCell = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table-cell", + text: "", + title: "" + }) + }, + + _init: function () { + BI.PageTableCell.superclass._init.apply(this, arguments); + var label = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "nowrap", + height: this.options.height, + text: this.options.text, + title: this.options.title, + value: this.options.value, + lgap: 5, + rgap: 5 + }); + + if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) { + this.element.css(this.options.styles); + } + } +}); + +BI.shortcut("bi.page_table_cell", BI.PageTableCell);/** + * 分页表格 + * + * Created by GUY on 2016/2/15. + * @class BI.PageTable + * @extends BI.Widget + */ +BI.PageTable = BI.inherit(BI.Widget, { + + _const: { + scrollWidth: 18, + minScrollWidth: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table", + el: { + type: "bi.sequence_table" + }, + pager: { + horizontal: { + pages: false, //总页数 + curr: 1, //初始化当前页, pages为数字时可用 + + hasPrev: BI.emptyFn, + hasNext: BI.emptyFn, + firstPage: 1, + lastPage: BI.emptyFn + }, + vertical: { + pages: false, //总页数 + curr: 1, //初始化当前页, pages为数字时可用 + + hasPrev: BI.emptyFn, + hasNext: BI.emptyFn, + firstPage: 1, + lastPage: BI.emptyFn + } + }, + + itemsCreator: BI.emptyFn, + + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.PageTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.hCurr = 1; + this.vCurr = 1; + + this.table = BI.createWidget(o.el, { + type: "bi.sequence_table", + width: o.width, + height: o.height && o.height - 30, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.pager = BI.createWidget(o.pager, { + type: "bi.direction_pager", + height: 30 + }); + this.pager.on(BI.Pager.EVENT_CHANGE, function () { + var vpage = this.getVPage && this.getVPage(); + if (BI.isNull(vpage)) { + vpage = this.getCurrentPage(); + } + var hpage = this.getHPage && this.getHPage(); + o.itemsCreator({ + vpage: vpage, + hpage: hpage + }, function (items, header, crossItems, crossHeader) { + self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage); + self.table.setHPage && self.table.setHPage(hpage); + self.populate.apply(self, arguments); + }); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.table, + left: 0, + top: 0 + }, { + el: this.pager, + left: 0, + right: 0, + bottom: 0 + }] + }) + }, + + setHPage: function (v) { + this.hCurr = v; + this.pager.setHPage && this.pager.setHPage(v); + this.table.setHPage && this.table.setHPage(v); + }, + + setVPage: function (v) { + this.vCurr = v; + this.pager.setVPage && this.pager.setVPage(v); + this.table.setVPage && this.table.setVPage(v); + }, + + getHPage: function () { + var hpage = this.pager.getHPage && this.pager.getHPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + hpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + return this.hpage; + }, + + getVPage: function () { + var vpage = this.pager.getVPage && this.pager.getVPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + vpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + return this.vpage; + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + var showPager = false; + if (this.pager.alwaysShowPager) { + showPager = true; + } else if (this.pager.hasHNext && this.pager.hasHNext()) { + showPager = true; + } else if (this.pager.hasHPrev && this.pager.hasHPrev()) { + showPager = true; + } else if (this.pager.hasVNext && this.pager.hasVNext()) { + showPager = true; + } else if (this.pager.hasVPrev && this.pager.hasVPrev()) { + showPager = true; + } else if (this.pager.hasNext && this.pager.hasNext()) { + showPager = true; + } else if (this.pager.hasPrev && this.pager.hasPrev()) { + showPager = true; + } + this.table.setHeight(height - (showPager ? 30 : 0)); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + restore: function () { + this.table.restore(); + }, + + attr: function () { + BI.PageTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function () { + this.pager.populate(); + this.table.populate.apply(this.table, arguments); + }, + + destroy: function () { + this.table.destroy(); + this.pager && this.pager.destroy(); + BI.PageTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.page_table', BI.PageTable);/** + * 路径选择 + * + * Created by GUY on 2015/12/4. + * @class BI.PathChooser + * @extends BI.Widget + */ +BI.PathChooser = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#d4dadd", + selectLineColor: "#3f8ce8" + }, + + _defaultConfig: function () { + return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-path-chooser", + items: [] + }) + }, + + _init: function () { + BI.PathChooser.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + _createRegions: function (regions) { + var self = this; + this.regions = BI.createWidgets(BI.map(regions, function (i, region) { + return { + type: "bi.path_region", + title: self.texts[region] || region + } + })); + this.regionMap = {}; + BI.each(regions, function (i, region) { + self.regionMap[region] = i; + }); + this.container = BI.createWidget({ + type: "bi.horizontal", + verticalAlign: "top", + scrollx: false, + scrolly: false, + hgap: 10, + items: this.regions + }); + BI.createWidget({ + type: "bi.vertical_adapt", + element: this, + scrollable: true, + hgap: 10, + items: [this.container] + }); + }, + + getRegionIndexById: function (id) { + var node = this.store[id]; + var regionType = node.get("region"); + return this.regionMap[regionType]; + }, + + _drawPath: function (start, offset, index) { + var self = this; + var starts = []; + if (BI.contains(this.start, start)) { + starts = this.start; + } else { + starts = [start]; + } + + BI.each(starts, function (i, s) { + BI.each(self.radios[s], function (i, rad) { + rad.setSelected(false); + }); + BI.each(self.lines[s], function (i, line) { + line.attr("stroke", self._const.lineColor); + }); + BI.each(self.regionIndexes[s], function (i, idx) { + self.regions[idx].reset(); + }); + }); + + BI.each(this.routes[start][index], function (i, id) { + var regionIndex = self.getRegionIndexById(id); + self.regions[regionIndex].setSelect(offset + index, id); + }); + var current = BI.last(this.routes[start][index]); + + while (current && this.routes[current] && this.routes[current].length === 1) { + BI.each(this.routes[current][0], function (i, id) { + var regionIndex = self.getRegionIndexById(id); + self.regions[regionIndex].setSelect(0, id); + }); + this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront(); + current = BI.last(this.routes[current][0]); + } + this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront(); + this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true); + }, + + _drawRadio: function (start, offset, index, x, y) { + var self = this; + var radio = BI.createWidget({ + type: "bi.radio", + cls: "path-chooser-radio", + selected: offset + index === 0, + start: start, + index: index + }); + radio.on(BI.Radio.EVENT_CHANGE, function () { + self._drawPath(start, offset, index); + self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index); + }); + if (!this.radios[start]) { + this.radios[start] = []; + } + this.radios[start].push(radio); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [{ + el: radio, + left: x - 6.5, + top: y - 6.5 + }] + }) + }, + + _drawLine: function (start, lines) { + var self = this; + if (!this.lines[start]) { + this.lines[start] = []; + } + if (!this.pathes[start]) { + this.pathes[start] = []; + } + var startRegionIndex = this.getRegionIndexById(start); + //start所在的位置,然后接着往下画其他的路径 + var offset = this.regions[startRegionIndex].getIndexByValue(start); + BI.each(lines, function (i, line) { + self.pathes[start][i] = []; + var idx = i + offset; + var path = ""; + var stop = 47.5 + 29 * idx; + var sleft = 50 + 100 * startRegionIndex; + var radioStartX = sleft, radioStartY = stop; + var etop = stop; + var endRegionIndex = self.getRegionIndexById(BI.last(line)); + var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line)); + var eleft = 50 + 100 * endRegionIndex; + if (BI.contains(self.start, start)) { + radioStartX = sleft - 50; + path += "M" + (sleft - 50) + "," + stop; + self.pathes[start][i].push({ + x: sleft - 50, + y: stop + }) + } else if (idx === 0) { + radioStartX = sleft + 50; + path += "M" + sleft + "," + stop; + self.pathes[start][i].push({ + x: sleft, + y: stop + }) + } else { + radioStartX = sleft + 50; + path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop; + self.pathes[start][i].push({ + x: sleft, + y: 47.5 + }); + self.pathes[start][i].push({ + x: sleft + 50, + y: 47.5 + }); + self.pathes[start][i].push({ + x: sleft + 50, + y: stop + }); + } + if (idx > 0) { + var endY = endOffset * 29 + 47.5; + path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY; + self.pathes[start][i].push({ + x: eleft - 50, + y: etop + }); + self.pathes[start][i].push({ + x: eleft - 50, + y: endY + }); + self.pathes[start][i].push({ + x: eleft, + y: endY + }); + } else { + path += "L" + eleft + "," + etop; + self.pathes[start][i].push({ + x: eleft, + y: etop + }); + } + + var graph = self.svg.path(path) + .attr({ + stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor, + 'stroke-dasharray': '-' + }); + self.lines[start].push(graph); + if (lines.length > 1) { + self.lines[start][0].toFront(); + } + //第一个元素无论有多少个都要显示radio + if (BI.contains(self.start, start)) { + self.lines[self.regions[0].getValueByIndex(0)][0].toFront(); + } + if (lines.length > 1 || BI.contains(self.start, start)) { + self._drawRadio(start, offset, i, radioStartX, radioStartY); + } + }); + }, + + _drawLines: function (routes) { + var self = this; + this.lines = {}; + this.pathes = {}; + this.radios = {}; + this.regionIndexes = {}; + BI.each(routes, function (k, route) { + if (!self.regionIndexes[k]) { + self.regionIndexes[k] = []; + } + BI.each(route, function (i, rs) { + BI.each(rs, function (j, id) { + var regionIndex = self.getRegionIndexById(id); + if (!BI.contains(self.regionIndexes[k], regionIndex)) { + self.regionIndexes[k].push(regionIndex); + } + }); + }) + }); + BI.each(routes, function (k, route) { + self._drawLine(k, route); + }); + }, + + _pushNodes: function (nodes) { + var self = this; + var indexes = []; + for (var i = 0; i < nodes.length; i++) { + var id = nodes[i]; + var index = self.getRegionIndexById(id); + indexes.push(index); + var region = self.regions[index]; + if (i === nodes.length - 1) { + if (!region.hasItem(id)) { + region.addItem(id, self.texts[id]); + } + break; + } + if (i > 0 || BI.contains(self.start, id)) { + region.addItem(id, self.texts[id]); + } + } + for (var i = BI.first(indexes); i < BI.last(indexes); i++) { + if (!BI.contains(indexes, i)) { + self.regions[i].addItem(""); + } + } + }, + + _createNodes: function () { + var self = this, o = this.options; + this.store = {}; + this.texts = {}; + this.start = []; + this.end = []; + BI.each(o.items, function (i, item) { + self.start.push(BI.first(item).value); + self.end.push(BI.last(item).value); + }); + this.start = BI.uniq(this.start); + this.end = BI.uniq(this.end); + var regions = []; + var tree = new BI.Tree(); + var branches = {}, max = 0; + BI.each(o.items, function (i, items) { + BI.each(items, function (j, item) { + if (!BI.has(branches, item.value)) { + branches[item.value] = 0; + } + branches[item.value]++; + max = Math.max(max, branches[item.value]); + var prev = {}; + if (j > 0) { + prev = items[j - 1]; + } + var parent = self.store[prev.value || ""]; + var node = self.store[item.value] || new BI.Node(item.value); + node.set(item); + self.store[item.value] = node; + self.texts[item.value] = item.text; + self.texts[item.region] = item.regionText; + parent = BI.isNull(parent) ? tree.getRoot() : parent; + if (parent.getChildIndex(item.value) === -1) { + tree.addNode(parent, node); + } + }) + }); + + //算出区域列表 + tree.traverse(function (node) { + BI.each(node.getChildren(), function (i, child) { + if (BI.contains(regions, child.get("region"))) { + var index1 = BI.indexOf(regions, node.get("region")); + var index2 = BI.indexOf(regions, child.get("region")); + //交换区域 + if (index1 > index2) { + var t = regions[index2]; + for (var j = index2; j < index1; j++) { + regions[j] = regions[j + 1]; + } + regions[index1] = t; + } + } else { + regions.push(child.get("region")); + } + }); + }); + this._createRegions(regions); + + //算出节点 + BI.each(branches, function (k, branch) { + if (branch < max) { + delete branches[k]; + } + }); + + //过滤节点 + var nodes = []; + var n = tree.getRoot(); + while (n && n.getChildrenLength() === 1) { + if (BI.has(branches, n.getChildren()[0].id)) { + delete branches[n.getChildren()[0].id]; + n = n.getChildren()[0]; + } else { + n = null; + } + } + tree.traverse(function (node) { + if (BI.has(branches, node.id)) { + nodes.push(node.id); + delete branches[node.id]; + } + }); + + //填充节点 + var routes = {}; + var s, e; + for (var i = 0, len = nodes.length; i < len + 1; i++) { + if (len === 0) { + s = []; + BI.each(this.start, function (i, id) { + s.push(tree.search(id)); + }); + e = []; + BI.each(this.end, function (i, id) { + e.push(tree.search(id)); + }); + } else if (i === len) { + s = e; + e = []; + BI.each(this.end, function (i, id) { + e.push(tree.search(id)); + }); + } else if (i === 0) { + s = []; + BI.each(this.start, function (i, id) { + s.push(tree.search(id)); + }); + e = [tree.search(nodes[i])]; + } else { + s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])]; + e = [tree.search(s[0], nodes[i])]; + } + BI.each(s, function (i, n) { + tree._recursion(n, [n.id], function (node, route) { + if (BI.contains(e, node)) { + if (!routes[n.id]) { + routes[n.id] = []; + } + routes[n.id].push(route); + self._pushNodes(route); + if (e.length <= 1) { + return true; + } + } + }) + }); + } + this.routes = routes; + this._drawLines(routes); + }, + + _unselectAllPath: function () { + var self = this; + BI.each(this.radios, function (idx, rad) { + BI.each(rad, function (i, r) { + r.setSelected(false); + }); + }); + BI.each(this.lines, function (idx, line) { + BI.each(line, function (i, li) { + li.attr("stroke", self._const.lineColor); + }); + }); + BI.each(this.regions, function (idx, region) { + region.reset(); + }); + }, + + populate: function (items) { + this.options.items = items || []; + var self = this; + this.empty(); + if (this.options.items.length <= 0) { + return; + } + this.svg = BI.createWidget({ + type: "bi.svg" + }); + this._createNodes(); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [{ + el: this.svg, + top: 0, + left: 0, + right: 0, + bottom: 0 + }] + }); + }, + + setValue: function (v) { + this._unselectAllPath(); + var nodes = BI.keys(this.routes), self = this; + var result = [], array = []; + BI.each(v, function (i, val) { + if (BI.contains(nodes, val)) { + if (array.length > 0) { + array.push(val); + result.push(array); + array = []; + } + } + array.push(val); + }); + if (array.length > 0) { + result.push(array); + } + //画这n条路径 + BI.each(result, function (idx, path) { + var start = path[0]; + var index = BI.findIndex(self.routes[start], function (idx, p) { + if (BI.isEqual(path, p)) { + return true; + } + }); + if (index >= 0) { + var startRegionIndex = self.getRegionIndexById(start); + var offset = self.regions[startRegionIndex].getIndexByValue(start); + self._drawPath(start, offset, index); + } + }); + }, + + getValue: function () { + var path = []; + BI.each(this.regions, function (i, region) { + var val = region.getValue(); + if (BI.isKey(val)) { + path.push(val); + } + }); + return path; + } +}); +BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE"; +BI.shortcut("bi.path_chooser", BI.PathChooser);/** + * 路径选择区域 + * + * Created by GUY on 2015/12/4. + * @class BI.PathRegion + * @extends BI.Widget + */ +BI.PathRegion = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-path-region bi-background", + width: 80, + title: "" + }) + }, + + _init: function () { + BI.PathRegion.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.zIndex = 100; + var title = BI.createWidget({ + type: "bi.label", + text: o.title, + title: o.title, + height: 30 + }); + title.element.css("zIndex", this.zIndex--); + this.items = []; + this.vertical = BI.createWidget({ + type: "bi.vertical", + element: this, + bgap: 5, + hgap: 10, + items: [title] + }) + }, + + hasItem: function (val) { + return BI.any(this.items, function (i, item) { + return val === item.getValue(); + }); + }, + + addItem: function (value, text) { + if (BI.isKey(value)) { + var label = BI.createWidget({ + type: "bi.label", + cls: "path-region-label bi-card bi-border bi-list-item-select", + text: text, + value: value, + title: text || value, + height: 22 + }); + } else { + var label = BI.createWidget({ + type: "bi.layout", + height: 24 + }); + } + label.element.css("zIndex", this.zIndex--); + this.items.push(label); + this.vertical.addItem(label); + if (this.items.length === 1) { + this.setSelect(0, value); + } + }, + + reset: function () { + BI.each(this.items, function (i, item) { + item.element.removeClass("active"); + }); + }, + + setSelect: function (index, value) { + this.reset(); + if (this.items.length <= 0) { + return; + } + if (this.items.length === 1) { + this.items[0].element.addClass("active"); + return; + } + if (this.items[index].attr("value") === value) { + this.items[index].element.addClass("active"); + } + }, + + setValue: function (value) { + this.setSelect(this.getIndexByValue(value), value); + }, + + getValueByIndex: function (idx) { + return this.items[idx].attr("value"); + }, + + getIndexByValue: function (value) { + return BI.findIndex(this.items, function (i, item) { + return item.attr("value") === value; + }); + }, + + getValue: function () { + var res; + BI.any(this.items, function (i, item) { + if (item.element.hasClass("active")) { + res = item.getValue(); + return true; + } + }); + return res; + } +}); +BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE"; +BI.shortcut("bi.path_region", BI.PathRegion);/** + * 预览表列 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableCell + * @extends BI.Widget + */ +BI.PreviewTableCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableHeaderCell + * @extends BI.Widget + */ +BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-header-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTable + * @extends BI.Widget + */ +BI.PreviewTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table", + isNeedFreeze: false, + freezeCols: [], + rowSize: null, + columnSize: [], + headerRowSize: 30, + header: [], + items: [] + }); + }, + + _init: function () { + BI.PreviewTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + isNeedResize: false, + + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + rowSize: o.rowSize, + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + + header: BI.map(o.header, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_header_cell" + }, item); + }); + }), + items: BI.map(o.items, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_cell" + }, item); + }); + }) + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._adjustColumns(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._adjustColumns(); + }); + }, + + //是否有自适应调节的列,即列宽为"" + _hasAdaptCol: function (columnSize) { + return BI.any(columnSize, function (i, size) { + return size === ""; + }) + }, + + _isPercentage: function (columnSize) { + return columnSize[0] <= 1; + }, + + _adjustColumns: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + //如果存在百分比的情况 + if (this._isPercentage(o.columnSize)) { + if (this._hasAdaptCol(o.columnSize)) { + var findCols = [], remain = 0; + BI.each(o.columnSize, function (i, size) { + if (size === "") { + findCols.push(i); + } else { + remain += size; + } + }); + remain = 1 - remain; + var average = remain / findCols.length; + BI.each(findCols, function (i, col) { + o.columnSize[col] = average; + }); + } + var isRight = BI.first(o.freezeCols) !== 0; + var freezeSize = [], notFreezeSize = []; + BI.each(o.columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + freezeSize.push(size); + } else { + notFreezeSize.push(size); + } + }); + var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize); + BI.each(freezeSize, function (i, size) { + freezeSize[i] = size / sumFreezeSize; + }); + BI.each(notFreezeSize, function (i, size) { + notFreezeSize[i] = size / sumNotFreezeSize; + }); + this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]); + this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize))); + } + } else { + //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100% + if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) { + this.table.setRegionColumnSize(["100%"]); + } + } + }, + + setColumnSize: function (columnSize) { + return this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + return this.table.setHeaderColumnSize(columnSize); + }, + + setRegionColumnSize: function (columnSize) { + return this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize() + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize() + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + return this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + return this.table.setLeftHorizontalScroll(scrollLeft) + }, + + setRightHorizontalScroll: function (scrollLeft) { + return this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + populate: function (items, header) { + this.table.populate(items, header); + } +}); +BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE"; +BI.shortcut('bi.preview_table', BI.PreviewTable);/** + * 季度下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.QuarterCombo + * @extends BI.Widget + */ +BI.QuarterCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-quarter-combo", + behaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.QuarterCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = ""; + this.trigger = BI.createWidget({ + type: "bi.quarter_trigger" + }); + + this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.QuarterTrigger.EVENT_CHANGE, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.QuarterTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () { + if (self.combo.isViewVisible()) { + return; + } + if (this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getKey()); + } else if (!this.getKey()) { + self.setValue(); + } + self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); + }); + this.popup = BI.createWidget({ + type: "bi.quarter_popup", + behaviors: o.behaviors + }); + + this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + el: this.popup + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue() || ""; + } +}); + +BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.quarter_combo', BI.QuarterCombo);/** + * 季度展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.QuarterPopup + * @extends BI.Trigger + */ +BI.QuarterPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-quarter-popup", + behaviors: {} + }); + }, + + _init: function () { + BI.QuarterPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var items = [{ + text: Date._QN[01], + value: 1 + }, { + text: Date._QN[2], + value: 2 + }, { + text: Date._QN[3], + value: 3 + }, { + text: Date._QN[4], + value: 4 + }]; + items = BI.map(items, function (j, item) { + return BI.extend(item, { + type: "bi.text_item", + cls: "bi-list-item-active", + textAlign: "left", + whiteSpace: "nowrap", + once: false, + forceSelected: true, + height: 25 + }); + }); + + this.quarter = BI.createWidget({ + type: "bi.button_group", + element: this, + behaviors: o.behaviors, + items: BI.createItems(items, {}), + layouts: [{ + type: "bi.vertical" + }] + }); + + this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MonthPopup.EVENT_CHANGE); + } + }) + }, + + getValue: function () { + return this.quarter.getValue()[0]; + }, + + setValue: function (v) { + this.quarter.setValue([v]); + } +}); +BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/** + * 季度trigger + * + * Created by GUY on 2015/8/21. + * @class BI.QuarterTrigger + * @extends BI.Trigger + */ +BI.QuarterTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 30, + textWidth: 40, + errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-quarter-trigger bi-border", + height: 25 + }); + }, + _init: function () { + BI.QuarterTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: c.errorText + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + self.editor.setTitle(value); + } + self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_STOP); + }); + + BI.createWidget({ + element: this, + type: 'bi.htape', + items: [ + { + el: this.editor + }, { + el: { + type: "bi.text_button", + baseCls: "bi-trigger-quarter-text", + text: BI.i18nText("BI-Multi_Date_Quarter"), + width: c.textWidth + }, + width: c.textWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + + setValue: function (v) { + this.editor.setState(v); + this.editor.setValue(v); + this.editor.setTitle(v); + }, + + getKey: function () { + return this.editor.getValue(); + } +}); +BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.QuarterTrigger.EVENT_START = "EVENT_START"; +BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP"; +BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/** + * 关联视图字段Item + * + * Created by GUY on 2015/12/23. + * @class BI.RelationViewItem + * @extends BI.Widget + */ +BI.RelationViewItem = BI.inherit(BI.BasicButton, { + + _defaultConfig: function () { + return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-item bi-list-item-active", + height: 25, + hoverIn: BI.emptyFn, + hoverOut: BI.emptyFn + }); + }, + + _init: function () { + BI.RelationViewItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.element.hover(o.hoverIn, o.hoverOut); + var items = []; + if (o.isPrimary) { + items.push({ + type: "bi.icon", + width: 16, + height: 16, + title: BI.i18nText("BI-Primary_Key") + }); + } + items.push({ + type: "bi.label", + text: o.text, + value: o.value, + height: o.height, + textAlign: "left", + width: o.isPrimary ? 70 : 90 + }); + BI.createWidget({ + type: "bi.vertical_adapt", + element: this, + items: items, + cls: "primary-key-font", + lgap: 5 + }); + }, + + enableHover: function (opt) { + BI.RelationViewRegion.superclass.enableHover.apply(this, [{ + container: "body" + }]); + }, + + setSelected: function (b) { + this.element[b ? "addClass" : "removeClass"]("active"); + } +}); +BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/** + * 关联视图 + * + * Created by GUY on 2015/12/22. + * @class BI.RelationView + * @extends BI.Widget + */ +BI.RelationView = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#c4c6c6", + selectLineColor: "#009de3" + }, + + _defaultConfig: function () { + return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view", + items: [] + }); + }, + + _init: function () { + BI.RelationView.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + _calculateWidths: function () { + var widths = []; + BI.each(this.views, function (i, items) { + BI.each(items, function (j, obj) { + if (!widths[j]) { + widths[j] = BI.MIN; + } + widths[j] = Math.max(widths[j], obj.getWidth()); + }) + }); + return widths; + }, + + _calculateHeights: function () { + var heights = BI.makeArray(BI.size(this.views), BI.MIN); + BI.each(this.views, function (i, items) { + BI.each(items, function (j, obj) { + heights[i] = Math.max(heights[i], obj.getHeight()); + }) + }); + return heights; + }, + + _hoverIn: function (target) { + var self = this, c = this._const; + BI.each(this.relations, function (start, rs) { + BI.each(rs, function (end, relation) { + if (relation[0].primary.value === target || relation[0].foreign.value === target) { + self.lines[start][end].attr("stroke", c.selectLineColor).toFront(); + self.storeViews[start].setValue(relation[0].primary.value); + self.storeViews[end].setValue(relation[0].foreign.value); + } + }); + }); + }, + + _hoverOut: function (target) { + var self = this, c = this._const; + BI.each(this.relations, function (start, rs) { + BI.each(rs, function (end, relation) { + if (relation[0].primary.value === target || relation[0].foreign.value === target) { + self.lines[start][end].attr("stroke", c.lineColor); + self.storeViews[start].setValue([]); + self.storeViews[end].setValue([]); + } + }); + }); + }, + + previewRelationTables: function(relationTables, show) { + if (!show) { + BI.each(this.storeViews, function (i, view) { + view.toggleRegion(true); + view.setPreviewSelected(false); + }); + BI.each(this.lines, function (i, lines) { + BI.each(lines, function (j, line) { + line.show(); + }); + }); + return; + } + BI.each(this.storeViews, function (id, view) { + if (!relationTables.contains(id)) { + view.toggleRegion(false); + } else { + view.setPreviewSelected(true); + } + }); + BI.each(this.lines, function (id, lines) { + BI.each(lines, function (cId, line) { + if (!relationTables.contains(id) || !relationTables.contains(cId)) { + line.hide(); + } + }); + }); + }, + + populate: function (items) { + var self = this, o = this.options, c = this._const; + o.items = items || []; + this.empty(); + this.svg = BI.createWidget({ + type: "bi.svg" + }); + + //算出所有的区域和关联 + var regions = this.regions = {}, relations = this.relations = {}; + BI.each(items, function (i, item) { + var pr = item.primary.region, fr = item.foreign && item.foreign.region; + if (pr && !relations[pr]) { + relations[pr] = {}; + } + if (pr && fr && !relations[pr][fr]) { + relations[pr][fr] = []; + } + if (pr && !regions[pr]) { + regions[pr] = []; + } + if (fr && !regions[fr]) { + regions[fr] = []; + } + if (pr && !BI.deepContains(regions[pr], item.primary)) { + regions[pr].push(item.primary); + } + if (fr && !BI.deepContains(regions[fr], item.foreign)) { + regions[fr].push(item.foreign); + } + pr && fr && relations[pr][fr].push(item); + }); + //求拓扑 + var topology = []; + var rs = BI.clone(regions), store = {}; + while (!BI.isEmpty(rs)) { + var clone = BI.clone(rs); + BI.each(o.items, function (i, item) { + if (!store[item.primary.region]) { + delete clone[item.foreign && item.foreign.region]; + } + }); + topology.push(BI.keys(clone)); + BI.extend(store, clone); + BI.each(clone, function (k, v) { + delete rs[k]; + }); + } + //构建视图 + var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {}; + var verticals = []; + BI.each(topology, function (i, items) { + if (!views[i]) { + views[i] = {}; + } + var horizontal = []; + BI.each(items, function (j, region) { + var items = regions[region]; + views[i][j] = storeViews[region] = BI.createWidget({ + type: "bi.relation_view_region_container", + value: region, + header: items[0].regionTitle, + text: items.length > 0 ? items[0].regionText : "", + handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn, + items: items, + belongPackage: items.length > 0 ? items[0].belongPackage : true + }); + if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) { + views[i][j].doRedMark(items[0].keyword); + } + views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) { + self._hoverIn(v); + }); + views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) { + self._hoverOut(v); + }); + views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) { + self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v); + }); + indexes[region] = {i: i, j: j}; + horizontal.push(views[i][j]); + }); + verticals.push({ + type: "bi.horizontal", + items: horizontal + }) + }); + + //求每一行的高度 + var heights = this._calculateHeights(); + + //求每一列的宽度 + var widths = this._calculateWidths(); + + //求相对宽度和高度 + var offsetWidths = [0], offsetHeights = [0]; + BI.each(heights, function (i, h) { + if (i === 0) { + return; + } + offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1]; + }); + BI.each(widths, function (i, w) { + if (i === 0) { + return; + } + offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1]; + }); + + //画线 + var lines = this.lines = {};//缓存所有的线 + BI.each(relations, function (start, rs) { + BI.each(rs, function (end, relation) { + var startIndex = indexes[start], endIndex = indexes[end]; + var top = 0, right = 1, bottom = 2, left = 3; + var startDirection = bottom, endDirection = top; + // if (startIndex.j > endIndex.j) { + // startDirection = left; + // endDirection = right; + // } else if (startIndex.j < endIndex.j) { + // startDirection = right; + // endDirection = left; + // } else if (startIndex.i < endIndex.i) { + // startDirection = bottom; + // endDirection = top; + // } else if (startIndex.i > endIndex.i) { + // startDirection = top; + // endDirection = bottom; + // } + var draw = function (i, j, direction, isForeign) { + var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; + var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; + var path = "", position; + switch (direction) { + case top: + position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + x + "," + (y - 10); + y -= 10; + break; + case right: + position = views[i][j].getRightPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + (x + 10) + "," + y; + x += 10; + break; + case bottom: + position = views[i][j].getBottomPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + x + "," + (y + 10); + y += 10; + break; + case left: + position = views[i][j].getLeftPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + (x - 10) + "," + y; + x -= 10; + break; + } + return {x: x, y: y, path: path}; + }; + var path = ""; + var si = draw(startIndex.i, startIndex.j, startDirection); + var ei = draw(endIndex.i, endIndex.j, endDirection, true); + path += si.path + ei.path; + if (!lines[start]) { + lines[start] = {}; + } + path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y; + var line = lines[start][end] = self.svg.path(path) + .attr({"stroke": c.lineColor, "stroke-width": "2"}) + .hover(function () { + line.attr("stroke", c.selectLineColor).toFront(); + storeViews[start].setValue(relation[0].primary.value); + storeViews[end].setValue(relation[0].foreign.value); + }, function () { + line.attr("stroke", c.lineColor); + storeViews[start].setValue([]); + storeViews[end].setValue([]); + }); + }); + }); + var container = BI.createWidget(); + BI.createWidget({ + type: "bi.vertical", + element: container, + items: verticals + }); + BI.createWidget({ + type: "bi.absolute", + element: container, + items: [{ + el: this.svg, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }); + + BI.createWidget({ + type: "bi.center_adapt", + scrollable: true, + element: this, + items: [container] + }); + } +}); +BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE"; +BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW"; +BI.shortcut('bi.relation_view', BI.RelationView);/** + * Created by Young's on 2017/3/10. + */ +BI.RelationViewRegionContainer = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-region-container", + width: 150 + }); + }, + + _init: function () { + BI.RelationViewRegionContainer.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.region = BI.createWidget({ + type: "bi.relation_view_region", + value: o.value, + header: o.header, + text: o.text, + handler: o.handler, + items: o.items, + belongPackage: o.belongPackage + }); + this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v); + }); + this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v); + }); + this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v); + }); + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.region], + width: this.region.getWidth(), + height: this.region.getHeight() + }); + }, + + doRedMark: function () { + this.region.doRedMark.apply(this.region, arguments); + }, + + unRedMark: function () { + this.region.unRedMark.apply(this.region, arguments); + }, + + getWidth: function () { + return this.region.getWidth(); + }, + + getHeight: function () { + return this.region.getHeight(); + }, + + //获取上方开始划线的位置 + getTopLeftPosition: function () { + return this.region.getTopLeftPosition(); + }, + + getTopRightPosition: function () { + return this.region.getTopRightPosition(); + }, + + getBottomPosition: function () { + return this.region.getBottomPosition(); + }, + + getLeftPosition: function () { + return this.region.getLeftPosition(); + }, + + getRightPosition: function () { + return this.region.getRightPosition(); + }, + + setValue: function (v) { + this.region.setValue(v); + }, + + toggleRegion: function (v) { + v === true ? this.region.element.fadeIn() : this.region.element.fadeOut(); + }, + + setPreviewSelected: function(v) { + this.region.setPreviewSelected(v); + } +}); +BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; +BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; +BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; +BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/** + * 关联视图 + * + * Created by GUY on 2015/12/23. + * @class BI.RelationViewRegion + * @extends BI.BasicButton + */ +BI.RelationViewRegion = BI.inherit(BI.BasicButton, { + + _defaultConfig: function () { + return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-region cursor-pointer", + width: 150, + text: "", + value: "", + header: "", + items: [], + belongPackage: true + }); + }, + + _init: function () { + BI.RelationViewRegion.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.preview = BI.createWidget({ + type: "bi.icon_button", + cls: "relation-table-preview-font", + width: 25, + height: 25, + stopPropagation: true + }); + this.preview.on(BI.IconButton.EVENT_CHANGE, function () { + self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected()); + }); + + this.title = BI.createWidget({ + type: "bi.label", + height: 25, + width: 70, + text: o.text, + value: o.value, + textAlign: "left" + }); + //title放body上 + if (BI.isKey(o.header)) { + this.title.setTitle(o.header, { + container: "body" + }) + } + + this.button_group = BI.createWidget({ + type: "bi.button_group", + items: this._createItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [{ + type: "bi.vertical", + cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), + items: [{ + type: "bi.vertical_adapt", + cls: "relation-view-region-title bi-border-bottom", + items: [this.preview, this.title] + }, this.button_group] + }], + hgap: 25, + vgap: 20 + }) + }, + + _createItems: function (items) { + var self = this; + return BI.map(items, function (i, item) { + return BI.extend(item, { + type: "bi.relation_view_item", + hoverIn: function () { + self.setValue(item.value); + self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); + }, + hoverOut: function () { + self.setValue([]); + self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value); + } + }) + }); + }, + + doRedMark: function () { + this.title.doRedMark.apply(this.title, arguments); + }, + + unRedMark: function () { + this.title.unRedMark.apply(this.title, arguments); + }, + + getWidth: function () { + return this.options.width; + }, + + getHeight: function () { + return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; + }, + + //获取上方开始划线的位置 + getTopLeftPosition: function () { + return { + x: 25 + 10, + y: 20 + } + }, + + getTopRightPosition: function () { + return { + x: this.getWidth() - 25 - 10, + y: 20 + } + }, + + getBottomPosition: function () { + return { + x: 25 + 10, + y: this.getHeight() - 20 + } + }, + + getLeftPosition: function () { + return { + x: 25, + y: 20 + 10 + } + }, + + getRightPosition: function () { + return { + x: this.getWidth() - 25, + y: 20 + 10 + } + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + setPreviewSelected: function(v) { + this.preview.setSelected(v); + } +}); +BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; +BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; +BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; +BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/** + * 自适应宽度的表格 + * + * Created by GUY on 2016/2/3. + * @class BI.ResponisveTable + * @extends BI.Widget + */ +BI.ResponisveTable = BI.inherit(BI.Widget, { + + _const: { + perColumnSize: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-responsive-table", + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 + return BI.isEqual(row1, row2); + }, + + columnSize: [], + headerRowSize: 25, + footerRowSize: 25, + rowSize: 25, + + regionColumnSize: false, + + header: [], + footer: false, + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.ResponisveTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + footerRowSize: o.footerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + header: o.header, + footer: o.footer, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { + //important:在冻结并自适应列宽的情况下要随时变更表头宽度 + if (o.isNeedResize === true && self._isAdaptiveColumn()) { + self._resizeHeader(); + } + self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + + this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { + self._resizeBody(); + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + _initRegionSize: function () { + var o = this.options; + if (o.isNeedFreeze === true) { + var regionColumnSize = this.table.getRegionColumnSize(); + var maxWidth = this.table.element.width(); + if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) { + var freezeCols = o.freezeCols; + if (freezeCols.length === 0) { + this.table.setRegionColumnSize([0, "fill"]); + } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) { + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } else { + this.table.setRegionColumnSize(["fill", 0]); + } + } + } + }, + + _getBlockSize: function () { + var o = this.options; + var columnSize = this.table.getCalculateColumnSize(); + if (o.isNeedFreeze === true) { + var columnSizeLeft = [], columnSizeRight = []; + BI.each(columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + columnSizeLeft.push(size); + } else { + columnSizeRight.push(size); + } + }); + //因为有边框,所以加上数组长度的参数调整 + var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, + sumRight = BI.sum(columnSizeRight) + columnSizeRight.length; + return { + sumLeft: sumLeft, + sumRight: sumRight, + left: columnSizeLeft, + right: columnSizeRight + } + } + return { + size: columnSize, + sum: BI.sum(columnSize) + columnSize.length + }; + }, + + _isAdaptiveColumn: function (columnSize) { + return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05); + }, + + _resizeHeader: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + //若是当前处于自适应调节阶段 + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.table.setHeaderColumnSize(columnSize); + } else { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + var columnSizeLeft = block.left, columnSizeRight = block.right; + columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft; + columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight; + + var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight); + newLeft[newLeft.length - 1] = ""; + newRight[newRight.length - 1] = ""; + this.table.setColumnSize(newLeft.concat(newRight)); + + block = self._getBlockSize(); + if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) { + columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1] + } + if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) { + columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1] + } + + self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight)); + } + } else { + if (!this._isAdaptiveColumn()) { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sum = block.sum; + var size = block.size; + + size[size.length - 1] += regionColumnSize[0] - sum; + + var newSize = BI.clone(size); + newSize[newSize.length - 1] = ""; + this.table.setColumnSize(newSize); + block = this._getBlockSize(); + + if (size[size.length - 1] < block.size[block.size.length - 1]) { + size[size.length - 1] = block.size[block.size.length - 1] + } + this.table.setColumnSize(size); + } + } + }, + + _resizeBody: function () { + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.setColumnSize(columnSize); + } + }, + + _adjustRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) { + this.table.setRegionColumnSize([sumLeft, "fill"]); + } + this._resizeRegion(); + } + }, + + _resizeRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var maxWidth = this.table.element.width(); + if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) { + var freezeCols = o.freezeCols; + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } + } + }, + + + resize: function () { + this.table.resize(); + this._resizeRegion(); + this._resizeHeader(); + }, + + setColumnSize: function (columnSize) { + this.table.setColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + this.table.setHeaderColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + setRegionColumnSize: function (columnSize) { + this.table.setRegionColumnSize(columnSize); + this._resizeHeader(); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize(); + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize(); + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + attr: function () { + BI.ResponisveTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function (items) { + var self = this, o = this.options; + this.table.populate.apply(this.table, arguments); + if (o.isNeedFreeze === true) { + BI.nextTick(function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + }); + } + } +}); +BI.shortcut('bi.responsive_table', BI.ResponisveTable);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.first_tree_node_checkbox", + stopPropagation: true + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 25, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.last_tree_node_checkbox", + stopPropagation: true + }) + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 25, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 25 + }) + }, + _init: function () { + BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.mid_tree_node_checkbox", + stopPropagation: true + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 25, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/** + * @class BI.SelectTreeCombo + * @extends BI.Widget + */ +BI.SelectTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-tree-combo", + height: 30, + text: "", + items: [] + }); + }, + + _init: function () { + BI.SelectTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }); + + this.popup = BI.createWidget({ + type: "bi.select_tree_popup", + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); + + +BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/** + * @class BI.SelectTreeExpander + * @extends BI.Widget + */ +BI.SelectTreeExpander = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-tree-expander", + trigger: "click", + toggle: true, + direction: "bottom", + isDefaultInit: true, + el: {}, + popup: {} + }); + }, + + _init: function () { + BI.SelectTreeExpander.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget(BI.extend({stopPropagation: true}, o.el)); + this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.expander.setValue([]); + } + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.expander = BI.createWidget({ + type: "bi.expander", + element: this, + trigger: o.trigger, + toggle: o.toggle, + direction: o.direction, + isDefaultInit: o.isDefaultInit, + el: this.trigger, + popup: o.popup + }); + this.expander.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + self.trigger.setSelected(false); + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + setValue: function (v) { + if (BI.contains(v, this.trigger.getValue())) { + this.trigger.setSelected(true); + this.expander.setValue([]); + } else { + this.trigger.setSelected(false); + this.expander.setValue(v); + } + }, + + getValue: function () { + if (this.trigger.isSelected()) { + return [this.trigger.getValue()]; + } + return this.expander.getValue(); + }, + + populate: function (items) { + this.expander.populate(items); + } +}); + +BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/** + * @class BI.SelectTreePopup + * @extends BI.Pane + */ + +BI.SelectTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-tree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + items: [] + }); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {layer: layer}; + node.id = node.id || BI.UUID(); + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + self._formatItems(node.children); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.last_tree_leaf_item"; + break; + default : + extend.type = "bi.mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _init: function () { + BI.SelectTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.level_tree', + expander: { + type: "bi.select_tree_expander", + isDefaultInit: true + }, + items: this._formatItems(BI.Tree.transformToTreeFormat(o.items)), + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.SelectTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.select_tree_popup", BI.SelectTreePopup);/** + * + * Created by GUY on 2016/8/10. + * @class BI.SequenceTableDynamicNumber + * @extends BI.SequenceTableTreeNumber + */ +BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-sequence-table-dynamic-number" + }); + }, + + _init: function () { + BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments); + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount(node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + } +}); +BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableListNumber + * @extends BI.Widget + */ +BI.SequenceTableListNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-list-number", + isNeedFreeze: false, + scrollTop: 0, + startSequence: 1,//开始的序号 + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: null, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [], + + pageSize: 20 + }); + }, + + _init: function () { + BI.SequenceTableListNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.start = o.startSequence; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: o.headerRowSize * o.header.length - 2 + }, { + el: {type: "bi.layout"}, + height: 2 + }, { + el: this.scrollContainer + }] + }); + this._populate(); + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = o.headerRowSize * o.header.length - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + this.container.setHeight(o.items.length * o.rowSize); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth()); + var start = Math.floor(scrollTop / o.rowSize); + var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize); + var renderedCells = [], renderedKeys = []; + for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) { + var index = BI.deepIndexOf(this.renderedKeys, this.start + i); + var top = i * o.rowSize; + if (index > -1) { + if (o.rowSize !== this.renderedCells[index]._height) { + this.renderedCells[index]._height = o.rowSize; + this.renderedCells[index].el.setHeight(o.rowSize); + } + if (this.renderedCells[index].top !== top) { + this.renderedCells[index].top = top; + this.renderedCells[index].el.element.css("top", top + "px"); + } + renderedCells.push(this.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + height: o.rowSize, + text: this.start + i, + styleGetter: function (index) { + return function () { + return o.sequenceCellStyleGetter(self.start + i - 1); + } + }(cnt) + })); + renderedCells.push({ + el: child, + left: 0, + top: top, + _height: o.rowSize + }); + } + renderedKeys.push(this.start + i); + } + + //已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]) + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + }, + + _populate: function () { + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + v = v < 1 ? 1 : v; + var o = this.options; + this.start = (v - 1) * o.pageSize + 1; + }, + + _restore: function () { + var o = this.options; + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + } + if (header && header !== this.options.header) { + o.header = header; + } + this._populate(); + } +}); +BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/** + * 带有序号的表格 + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTable + * @extends BI.Widget + */ +BI.SequenceTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table", + el: { + type: "bi.adaptive_table" + }, + + sequence: {}, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [], + + showSequence: false, + startSequence: 1//开始的序号 + }); + }, + + _init: function () { + BI.SequenceTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.sequence = BI.createWidget(o.sequence, { + type: "bi.sequence_table_list_number", + invisible: o.showSequence === false, + startSequence: o.startSequence, + isNeedFreeze: o.isNeedFreeze, + header: o.header, + items: o.items, + crossHeader: o.crossHeader, + crossItems: o.crossItems, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + width: 60, + height: o.height && o.height - BI.GridTableScrollbar.SIZE, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter + }); + this.table = BI.createWidget(o.el, { + type: "bi.adaptive_table", + width: o.showSequence === true ? o.width - 60 : o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { + if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { + self.sequence.setVerticalScroll(this.getVerticalScroll()); + self.sequence.populate(); + } + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.htape = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.sequence, + left: 0, + top: 0 + }, { + el: this.table, + top: 0, + left: o.showSequence === true ? 60 : 0 + }] + }); + this._populate(); + }, + + _populate: function () { + var o = this.options; + this.sequence.attr({ + items: o.items, + header: o.header, + crossItems: o.crossItems, + crossHeader: o.crossHeader + }); + if (o.showSequence === true) { + this.sequence.setVisible(true); + this.table.element.css("left", "60px"); + this.table.setWidth(o.width - 60); + } else { + this.sequence.setVisible(false); + this.table.element.css("left", "0px"); + this.table.setWidth(o.width); + } + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(this.options.showSequence ? width - 60 : width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + hasLeftHorizontalScroll: function () { + return this.table.hasLeftHorizontalScroll(); + }, + + hasRightHorizontalScroll: function () { + return this.table.hasRightHorizontalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + this.sequence.setVerticalScroll(scrollTop); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setVPage: function (page) { + this.sequence.setVPage && this.sequence.setVPage(page); + }, + + setHPage: function (page) { + this.sequence.setHPage && this.sequence.setHPage(page); + }, + + attr: function () { + BI.SequenceTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + this.sequence.attr.apply(this.sequence, arguments); + }, + + restore: function () { + this.table.restore(); + this.sequence.restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items) { + o.items = items; + } + if (header) { + o.header = header; + } + if (crossItems) { + o.crossItems = crossItems; + } + if (crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + this.table.populate.apply(this.table, arguments); + this.sequence.populate.apply(this.sequence, arguments); + this.sequence.setVerticalScroll(this.table.getVerticalScroll()); + }, + + destroy: function () { + this.table.destroy(); + BI.SequenceTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.sequence_table', BI.SequenceTable);/** + * @class BI.SingleTreeCombo + * @extends BI.Widget + */ +BI.SingleTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-combo", + trigger: {}, + height: 30, + text: "", + items: [] + }); + }, + + _init: function () { + BI.SingleTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget(BI.extend({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }, o.trigger)); + + this.popup = BI.createWidget({ + type: "bi.single_tree_popup", + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments); + }); + + this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); + }); + }, + + populate: function (items) { + this.combo.populate(items); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); + +BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE"; +BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/** + * @class BI.SingleTreePopup + * @extends BI.Pane + */ + +BI.SingleTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + items: [] + }); + }, + + _init: function () { + BI.SingleTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.level_tree', + expander: { + isDefaultInit: true + }, + items: o.items, + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.SingleTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.single_tree_popup", BI.SingleTreePopup);/** + * @class BI.SingleTreeTrigger + * @extends BI.Trigger + */ + +BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-trigger", + height: 30, + text: "", + items: [] + }); + }, + + _init: function () { + BI.SingleTreeTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.select_text_trigger", + element: this, + text: o.text, + items: o.items, + height: o.height + }); + }, + + _checkTitle: function () { + var self = this, val = this.getValue(); + BI.any(this.options.items, function (i, item) { + if (val.contains(item.value)) { + self.trigger.setTitle(item.text || item.value); + return true; + } + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.options.value = v; + this.trigger.setValue(v); + this._checkTitle(); + }, + + getValue: function () { + return this.options.value || []; + }, + + populate: function (items) { + BI.SingleTreeTrigger.superclass.populate.apply(this, arguments); + this.trigger.populate(items); + } + +}); + +BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/** + * 可以单选多选切换的树 + * + * Created by GUY on 2015/12/21. + * @class BI.SwitchTree + * @extends BI.Widget + */ +BI.SwitchTree = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-switch-tree", + items: [] + }); + }, + + _init: function () { + BI.SwitchTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tab = BI.createWidget({ + type: "bi.tab", + element: this, + tab: null, + defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect, + cardCreator: BI.bind(this._createTree, this) + }); + }, + + _createTree: function (type) { + var self = this, o = this.options; + switch (type) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree = BI.createWidget({ + type: "bi.multilayer_single_level_tree", + isDefaultInit: true, + items: BI.deepClone(o.items) + }); + this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.levelTree; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree = BI.createWidget({ + type: "bi.simple_tree", + items: this._removeIsParent(BI.deepClone(o.items)) + }); + this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.tree; + } + }, + + _removeIsParent: function(items) { + BI.each(items, function(i, item) { + BI.isNotNull(item.isParent) && delete item.isParent; + }); + return items; + }, + + switchSelect: function () { + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.setSelect(BI.SwitchTree.SelectType.MultiSelect); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.setSelect(BI.SwitchTree.SelectType.SingleSelect); + break; + } + }, + + setSelect: function (v) { + this.tab.setSelect(v); + }, + + getSelect: function () { + return this.tab.getSelect(); + }, + + setValue: function (v) { + this.storeValue = v; + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree.setValue(v); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree.setValue(v); + break; + } + }, + + getValue: function () { + return this.tab.getValue(); + }, + + populate: function (items) { + this.options.items = items; + if (BI.isNotNull(this.levelTree)) { + this.levelTree.populate(BI.deepClone(items)); + } + if (BI.isNotNull(this.tree)) { + this.tree.populate(this._removeIsParent(BI.deepClone(items))); + } + } +}); +BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; +BI.SwitchTree.SelectType = { + SingleSelect: BI.Selection.Single, + MultiSelect: BI.Selection.Multi +}; +BI.shortcut('bi.switch_tree', BI.SwitchTree); +/** + * 年份下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.YearCombo + * @extends BI.Widget + */ +BI.YearCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-combo", + behaviors: {}, + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.YearCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = ""; + this.trigger = BI.createWidget({ + type: "bi.year_trigger", + min: o.min, + max: o.max + }); + this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.YearTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_STOP, function () { + self.combo.showView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () { + if (self.combo.isViewVisible()) { + return; + } + if (this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getKey()); + } else if (!this.getKey()) { + self.setValue(); + } + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + destroyWhenHide: true, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: { + type: "bi.year_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.YearPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + } + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + var value = self.trigger.getKey(); + if (BI.isNotNull(value)) { + self.popup.setValue(value); + } else if (!value && value !== self.storeValue) { + self.popup.setValue(self.storeValue); + } else { + self.setValue(); + } + self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_combo', BI.YearCombo);/** + * 年份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.YearPopup + * @extends BI.Trigger + */ +BI.YearPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-popup", + behaviors: {}, + min: '1900-01-01', //最小日期 + max: '2099-12-31' //最大日期 + }); + }, + + _createYearCalendar: function (v) { + var o = this.options, y = this._year; + + var calendar = BI.createWidget({ + type: "bi.year_calendar", + behaviors: o.behaviors, + min: o.min, + max: o.max, + logic: { + dynamic: true + }, + year: y + v * 12 + }); + calendar.setValue(this._year); + return calendar; + }, + + _init: function () { + BI.YearPopup.superclass._init.apply(this, arguments); + var self = this; + + this.selectedYear = this._year = new Date().getFullYear(); + + var backBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 25, + height: 25, + value: -1 + }); + + var preBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 25, + height: 25, + value: 1 + }); + + this.navigation = BI.createWidget({ + type: "bi.navigation", + element: this, + single: true, + logic: { + dynamic: true + }, + tab: { + cls: "year-popup-navigation bi-high-light bi-border-top", + height: 25, + items: [backBtn, preBtn] + }, + cardCreator: BI.bind(this._createYearCalendar, this), + + afterCardShow: function () { + this.setValue(self.selectedYear); + var calendar = this.getSelectedCard(); + backBtn.setEnable(!calendar.isFrontYear()); + preBtn.setEnable(!calendar.isFinalYear()); + } + }); + + this.navigation.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedYear = this.getValue(); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear); + }); + }, + + getValue: function () { + return this.selectedYear; + }, + + setValue: function (v) { + var o = this.options; + if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) { + v = new Date().getFullYear(); + this.selectedYear = ""; + this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); + this.navigation.setValue(""); + } else { + this.selectedYear = v; + this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); + this.navigation.setValue(v); + } + } +}); +BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.year_popup", BI.YearPopup);/** + * 年份trigger + * + * Created by GUY on 2015/8/21. + * @class BI.YearTrigger + * @extends BI.Trigger + */ +BI.YearTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 25, + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), + errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-year-trigger bi-border", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.YearTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid); + return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: c.errorText + }) + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.YearTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.YearTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + self.editor.setTitle(value); + } + self.fireEvent(BI.YearTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.YearTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.YearTrigger.EVENT_ERROR); + }); + BI.createWidget({ + element: this, + type: 'bi.htape', + items: [ + { + el: this.editor + }, { + el: { + type: "bi.text_button", + baseCls: "bi-trigger-year-text", + text: BI.i18nText("BI-Multi_Date_Year"), + width: c.triggerWidth + }, + width: c.triggerWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + setValue: function (v) { + this.editor.setState(v); + this.editor.setValue(v); + this.editor.setTitle(v); + }, + getKey: function () { + return this.editor.getValue() | 0; + } +}); +BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.YearTrigger.EVENT_START = "EVENT_START"; +BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearTrigger.EVENT_STOP = "EVENT_STOP"; +BI.shortcut("bi.year_trigger", BI.YearTrigger);/** + * 年份 + 月份下拉框 + * + * @class BI.YearMonthCombo + * @extends BI.Widget + */ +BI.YearMonthCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-month-combo", + yearBehaviors: {}, + monthBehaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.YearMonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.year = BI.createWidget({ + type: "bi.year_combo", + behaviors: o.yearBehaviors + }); + + this.month = BI.createWidget({ + type: "bi.month_combo", + behaviors: o.monthBehaviors + }); + + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); + }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); + }); + this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.center", + element: this, + hgap: 5, + items: [this.year, this.month] + }); + + }, + + setValue: function (v) { + v = v || {}; + this.month.setValue(v.month); + this.year.setValue(v.year); + }, + + getValue: function () { + return { + year: this.year.getValue(), + month: this.month.getValue() + }; + } +}); +BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/** + * 年份 + 月份下拉框 + * + * @class BI.YearQuarterCombo + * @extends BI.Widget + */ +BI.YearQuarterCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-quarter-combo", + yearBehaviors: {}, + quarterBehaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.YearQuarterCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.year = BI.createWidget({ + type: "bi.year_combo", + behaviors: o.yearBehaviors + }); + + this.quarter = BI.createWidget({ + type: "bi.quarter_combo", + behaviors: o.quarterBehaviors + }); + + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); + }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); + }); + this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.center", + element: this, + hgap: 5, + items: [this.year, this.quarter] + }); + + }, + + setValue: function (v) { + v = v || {}; + this.quarter.setValue(v.quarter); + this.year.setValue(v.year); + }, + + getValue: function () { + return { + year: this.year.getValue(), + quarter: this.quarter.getValue() + }; + } +}); +BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与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 + }); + } + } +});/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与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) { + this.combo.setValue({ + type: BI.Selection.Multi, + value: v || [] + }); + }, + + getValue: function () { + var val = this.combo.getValue() || {}; + if (val.type === BI.Selection.All) { + return val.assist; + } + return val.value || []; + }, + + populate: function () { + this.combo.populate.apply(this, arguments); + } +}); +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.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);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._getTreeNode(parentValues, k); + var newParents = BI.clone(parentValues); + newParents.push(node.value); + createOneJson(node, node.parent && node.parent.id, 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 = BI.deepClone(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 = parentValues.concat(notSelectedValue); + //存储的值中存在这个值就把它删掉 + //例如选中了中国-江苏-南京, 取消中国或江苏或南京 + if (canFindKey(selectedValues, p)) { + //如果搜索的值在父亲链中 + if (isSearchValueInParent(p)) { + //例如选中了 中国-江苏, 搜索江苏, 取消江苏 + //例如选中了 中国-江苏, 搜索江苏, 取消中国 + self._deleteNode(selectedValues, p); + } else { + var searched = []; + var finded = search(parentValues, notSelectedValue, [], searched); + if (finded && BI.isNotEmptyArray(searched)) { + BI.each(searched, function (i, arr) { + var node = self._getNode(selectedValues, arr); + if (node) { + //例如选中了 中国-江苏-南京,搜索南京,取消中国 + self._deleteNode(selectedValues, arr); + } else { + //例如选中了 中国-江苏,搜索南京,取消中国 + expandSelectedValue(selectedValues, arr, BI.last(arr)); + } + }) + } + } + } + + //存储的值中不存在这个值,但父亲节点是全选的情况 + //例如选中了中国-江苏,取消南京 + //important 选中了中国-江苏,取消了江苏,但是搜索的是南京 + if (isChild(selectedValues, p)) { + var result = [], finded = false; + //如果parentValues中有匹配的值,说明搜索结果不在当前值下 + if (isSearchValueInParent(p)) { + finded = true; + } else { + //从当前值开始搜 + finded = search(parentValues, notSelectedValue, result); + p = parentValues; + } + + if (finded === true) { + //去掉点击的节点之后的结果集 + expandSelectedValue(selectedValues, p, notSelectedValue); + //添加去掉搜索的结果集 + if (result.length > 0) { + BI.each(result, function (i, strs) { + self._buildTree(selectedValues, strs); + }) + } + } + } + + } + + function expandSelectedValue(selectedValues, parents, notSelectedValue) { + var next = selectedValues; + var childrenCount = []; + var path = []; + //去掉点击的节点之后的结果集 + BI.some(parents, function (i, v) { + var t = next[v]; + if (t == null) { + if (i === 0) { + return true; + } + if (BI.isEmpty(next)) { + var split = parents.slice(0, i); + var expanded = self._getChildren(split); + path.push(split); + childrenCount.push(expanded.length); + //如果只有一个值且取消的就是这个值 + if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) { + for (var j = childrenCount.length - 1; j >= 0; j--) { + if (childrenCount[j] === 1) { + self._deleteNode(selectedValues, path[j]); + } else { + break; + } + } + } else { + BI.each(expanded, function (m, child) { + if (i === parents.length - 1 && child.value === notSelectedValue) { + return true; + } + next[child.value] = {}; + }); + } + next = next[v]; + } else { + return true; + // next = {}; + // next[v] = {}; + } + } else { + next = t; + } + }); + } + + function search(parents, current, result, searched) { + var newParents = BI.clone(parents); + newParents.push(current); + if (self._isMatch(parents, current, keyword)) { + searched && searched.push(newParents); + return true; + } + + var children = self._getChildren(newParents); + + var notSearch = []; + var can = false; + + BI.each(children, function (i, child) { + if (search(newParents, child.value, result, searched)) { + 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 isSearchValueInParent(parentValues) { + for (var i = 0, len = parentValues.length; i < len; i++) { + if (self._isMatch(parentValues.slice(0, parentValues.length - 1), parentValues[i], keyword)) { + return true; + } + } + return false; + } + + function canFindKey(selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + t = t[v]; + if (t == null) { + return false; + } + } + return true; + } + + function isChild(selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + if (!BI.has(t, v)) { + return false; + } + t = t[v]; + if (BI.isEmpty(t)) { + return true; + } + } + return false; + } + }, + + _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(parentValues, 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._getTreeNode(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]; + } + }, + + _getNode: function (selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + }, + + _deleteNode: function (selectedValues, values) { + var name = values[values.length - 1]; + var p = values.slice(0, values.length - 1); + var pNode = this._getNode(selectedValues, p); + if (pNode != null && pNode[name]) { + delete pNode[name]; + //递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = this._getNode(selectedValues, p); + if (pNode != null) { + delete pNode[name]; + } + } + } + }, + + _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 (parentValues, value, keyword) { + var node = this._getTreeNode(parentValues, value); + var finded = BI.Func.getSearchResult([node.text || node.value], keyword); + return finded.finded.length > 0 || finded.matched.length > 0; + }, + + _getTreeNode: 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._getTreeNode(parentValues.slice(0, parentValues.length - 1), value); + } else { + var parent = this.tree.getRoot(); + } + return parent.getChildren(); + }, + + _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) { + this.combo.setValue(v); + }, + + getValue: function () { + return this.combo.getValue(); + }, + + populate: function () { + 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(); + } + }, + + setSelectedValue: function (v) { + this.pane.setSelectedValue(v); + }, + + 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.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) + }); + } + } +});/** + * 简单的复选下拉框控件, 适用于数据量少的情况 + * 封装了字段处理逻辑 + * + * 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) { + this.combo.setValue(v); + }, + + getValue: function () { + var val = this.combo.getValue() || {}; + return { + type: val.type, + value: val.value + } + }, + + populate: function () { + this.combo.populate.apply(this, arguments); + } +}); +BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM"; +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"; +>>>>>>> 3903ca444e161ac208f69ba22c0a3136d7a0fa81 BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..7653e6612 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1776 @@ +{ + "name": "fineui", + "version": "1.0.0", + "lockfileVersion": 1, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", + "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=", + "dev": true + }, + "accepts": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", + "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", + "dev": true + }, + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "dev": true, + "optional": true + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "argparse": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", + "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", + "dev": true + }, + "array-find-index": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", + "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", + "dev": true + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", + "dev": true + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", + "dev": true, + "optional": true + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "dev": true, + "optional": true + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", + "dev": true, + "optional": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "dev": true, + "optional": true + }, + "body-parser": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.14.2.tgz", + "integrity": "sha1-EBXLH+LEQ4WCWVgdtTMy+NDPUPk=", + "dev": true, + "dependencies": { + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true + }, + "http-errors": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.3.1.tgz", + "integrity": "sha1-GX4izevUGYWF6GlO9nhhl7ke2UI=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.13", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz", + "integrity": "sha1-H4irpKsLFQjoMSrMOTRfNumS4vI=", + "dev": true + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + }, + "qs": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz", + "integrity": "sha1-qfMRQq9GjLcrJbMBNrokVoNJFr4=", + "dev": true + } + } + }, + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true + }, + "browserify-zlib": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", + "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "dev": true + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "bytes": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.2.0.tgz", + "integrity": "sha1-/TVGSkA/b5EXwt42Cez/nK4ABYg=", + "dev": true + }, + "camelcase": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", + "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", + "dev": true + }, + "camelcase-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true, + "optional": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true + }, + "clean-css": { + "version": "3.4.28", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.28.tgz", + "integrity": "sha1-vxlF6C/ICPVWlebd6uwBQA79A/8=", + "dev": true, + "dependencies": { + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true + } + } + }, + "cli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", + "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", + "dev": true, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true + } + } + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true, + "optional": true + }, + "coffee-script": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.10.0.tgz", + "integrity": "sha1-EpOLz5vhlI+gBvkuDEyegXBRCMA=", + "dev": true + }, + "colors": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "dev": true + }, + "commander": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "dev": true + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=", + "dev": true + }, + "content-type": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", + "integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=", + "dev": true + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", + "dev": true + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "dev": true, + "optional": true + }, + "currently-unhandled": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", + "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", + "dev": true + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "optional": true, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "optional": true + } + } + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "dateformat": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", + "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", + "dev": true + }, + "debug": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz", + "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=", + "dev": true + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "depd": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=", + "dev": true + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", + "dev": true + }, + "dom-serializer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", + "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "dev": true, + "dependencies": { + "domelementtype": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", + "dev": true + }, + "entities": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", + "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", + "dev": true + } + } + }, + "domelementtype": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", + "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", + "dev": true + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", + "dev": true + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "dev": true, + "optional": true + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "dev": true + }, + "encodeurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", + "dev": true + }, + "entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", + "dev": true + }, + "errno": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz", + "integrity": "sha1-uJbiOp5ei6M4cfyZar02NfyaHH0=", + "dev": true, + "optional": true + }, + "error-ex": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", + "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "dev": true + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esprima": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "dev": true + }, + "etag": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.0.tgz", + "integrity": "sha1-b2Ma7zNtbEY2K1F2QETOIWvjwFE=", + "dev": true + }, + "eventemitter2": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", + "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=", + "dev": true + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "express": { + "version": "4.15.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.15.3.tgz", + "integrity": "sha1-urZdDwOqgMNYQIly/HAPkWlEtmI=", + "dev": true + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", + "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=", + "dev": true + }, + "faye-websocket": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz", + "integrity": "sha1-TkkvjQTftviQA1B/btvy1QHnxvQ=", + "dev": true + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true + }, + "finalhandler": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.0.3.tgz", + "integrity": "sha1-70fneVDpmXgOhgIqVg4yF+DQzIk=", + "dev": true + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true + }, + "findup-sync": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz", + "integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=", + "dev": true, + "dependencies": { + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true + } + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "dev": true, + "optional": true + }, + "forwarded": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", + "integrity": "sha1-Ge+YdMSuHCl7zweP3mOgm2aoQ2M=", + "dev": true + }, + "fresh": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz", + "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "gaze": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.2.tgz", + "integrity": "sha1-hHIkZ3rbiHDWeSV+0ziP22HkAQU=", + "dev": true + }, + "get-stdin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", + "dev": true + }, + "getobject": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz", + "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=", + "dev": true + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "optional": true, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "optional": true + } + } + }, + "glob": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz", + "integrity": "sha1-IRuvr0nlJbjNkyYNFKsTYVKz9Xo=", + "dev": true + }, + "globule": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.0.tgz", + "integrity": "sha1-HcScaCLdnoovoAuiopUAboZkvQk=", + "dev": true, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + } + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true + }, + "grunt": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.0.1.tgz", + "integrity": "sha1-6HeHZOlEsY8yuw8QuQeEdcnftWs=", + "dev": true, + "dependencies": { + "grunt-cli": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.2.0.tgz", + "integrity": "sha1-VisRnrsGndtGSs4oRVAb6Xs1tqg=", + "dev": true + } + } + }, + "grunt-contrib-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/grunt-contrib-concat/-/grunt-contrib-concat-1.0.1.tgz", + "integrity": "sha1-YVCYYwhOhx1+ht5IwBUlntl3Rb0=", + "dev": true + }, + "grunt-contrib-cssmin": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-1.0.2.tgz", + "integrity": "sha1-FzTL09hMpzZHWLflj/GOUqpgu3Y=", + "dev": true + }, + "grunt-contrib-jshint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-jshint/-/grunt-contrib-jshint-1.1.0.tgz", + "integrity": "sha1-Np2QmyWTxA6L55lAshNAhQx5Oaw=", + "dev": true + }, + "grunt-contrib-less": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/grunt-contrib-less/-/grunt-contrib-less-1.4.1.tgz", + "integrity": "sha1-O73sC3XRLOqlXWKUNiXAsIYc328=", + "dev": true, + "dependencies": { + "async": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", + "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", + "dev": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + } + } + }, + "grunt-contrib-uglify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-1.0.2.tgz", + "integrity": "sha1-rmekb5FT7dTLEYE6Vetpxw19svs=", + "dev": true, + "dependencies": { + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + } + } + }, + "grunt-contrib-watch": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-watch/-/grunt-contrib-watch-1.0.0.tgz", + "integrity": "sha1-hKGnodar0m7VaEE0lscxM+mQAY8=", + "dev": true + }, + "grunt-known-options": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-1.1.0.tgz", + "integrity": "sha1-pCdO6zL6dl2lp6OxcSYXzjsUQUk=", + "dev": true + }, + "grunt-legacy-log": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-1.0.0.tgz", + "integrity": "sha1-+4bxgJhHvAfcR4Q/ns1srLYt8tU=", + "dev": true + }, + "grunt-legacy-log-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-1.0.0.tgz", + "integrity": "sha1-p7ji0Ps1taUPSvmG/BEnSevJbz0=", + "dev": true, + "dependencies": { + "lodash": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.3.0.tgz", + "integrity": "sha1-79nEpuxT87BUEkKZFcPkgk5NJaQ=", + "dev": true + } + } + }, + "grunt-legacy-util": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-1.0.0.tgz", + "integrity": "sha1-OGqnjcbtUJhsKxiVcmWxtIq7m4Y=", + "dev": true, + "dependencies": { + "lodash": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.3.0.tgz", + "integrity": "sha1-79nEpuxT87BUEkKZFcPkgk5NJaQ=", + "dev": true + } + } + }, + "gzip-size": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-1.0.0.tgz", + "integrity": "sha1-Zs+LEBBHInuVus5uodoMF37Vwi8=", + "dev": true + }, + "har-schema": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", + "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", + "dev": true, + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "dev": true, + "optional": true + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true + }, + "hawk": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "dev": true, + "optional": true + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", + "dev": true + }, + "hooker": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", + "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", + "dev": true + }, + "hosted-git-info": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", + "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", + "dev": true + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "http-errors": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.1.tgz", + "integrity": "sha1-X4uO2YrKVFZWv1cplzh/kEpyIlc=", + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz", + "integrity": "sha512-sr1ZQph3UwHTR0XftSbK85OvBbxe/abLGzEnPENCQwmHf7sck8Oyu4ob3LgBxWWxRoM+QszeUyl7jbqapu2TqA==", + "dev": true + }, + "image-size": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz", + "integrity": "sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w=", + "dev": true, + "optional": true + }, + "indent-string": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", + "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "ipaddr.js": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz", + "integrity": "sha1-HgOlL9rYOou7KyXL9JmLTP/NPew=", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "dev": true + }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "dev": true + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true, + "optional": true + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true, + "optional": true + }, + "js-yaml": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.5.5.tgz", + "integrity": "sha1-A3fDgBfKvHMisNH7zSWkkWQfL74=", + "dev": true + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true, + "optional": true + }, + "jshint": { + "version": "2.9.5", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.5.tgz", + "integrity": "sha1-HnJSkVzmgbQIJ+4UJIxG006apiw=", + "dev": true, + "dependencies": { + "lodash": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.7.0.tgz", + "integrity": "sha1-Nni9irmVBXwHreg27S7wh9qBHUU=", + "dev": true + } + } + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true, + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "optional": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true, + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", + "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=", + "dev": true, + "optional": true, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "optional": true + } + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true + }, + "less": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/less/-/less-2.7.2.tgz", + "integrity": "sha1-No1sxz4fsDmBGDKAkYdDxdz5s98=", + "dev": true + }, + "livereload-js": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-2.2.2.tgz", + "integrity": "sha1-bIclfmSKtHW8JOoldFftzB+NC8I=", + "dev": true + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "dev": true + }, + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "loud-rejection": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", + "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", + "dev": true + }, + "map-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "dev": true + }, + "maxmin": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-1.1.0.tgz", + "integrity": "sha1-cTZehKmd2Piz99X94vANHn9zvmE=", + "dev": true + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "dev": true + }, + "meow": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", + "dev": true + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", + "dev": true + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "dev": true + }, + "mime": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", + "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=", + "dev": true + }, + "mime-db": { + "version": "1.27.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", + "integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=", + "dev": true + }, + "mime-types": { + "version": "2.1.15", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", + "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "optional": true, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true, + "optional": true + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "dev": true + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true + }, + "normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "dev": true + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true + }, + "open": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/open/-/open-0.0.5.tgz", + "integrity": "sha1-QsPhjslUZra/DcQvOilFw/DK2Pw=", + "dev": true + }, + "pako": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", + "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "dev": true + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true + }, + "parseurl": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=", + "dev": true + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", + "dev": true + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "dev": true + }, + "performance-now": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", + "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", + "dev": true, + "optional": true + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true + }, + "pretty-bytes": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", + "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "dev": true, + "optional": true + }, + "proxy-addr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.4.tgz", + "integrity": "sha1-J+VF9pYKRKYn2bREZ+NcG2tM4vM=", + "dev": true + }, + "prr": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz", + "integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=", + "dev": true, + "optional": true + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true, + "optional": true + }, + "qs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", + "dev": true + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", + "dev": true + }, + "raw-body": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.1.7.tgz", + "integrity": "sha1-rf6s4uT7MJgFgBTQjActzFl1h3Q=", + "dev": true, + "dependencies": { + "bytes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", + "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.13", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz", + "integrity": "sha1-H4irpKsLFQjoMSrMOTRfNumS4vI=", + "dev": true + } + } + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true + }, + "redent": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", + "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true + }, + "request": { + "version": "2.81.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "dev": true, + "optional": true + }, + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true + }, + "rimraf": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", + "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", + "dev": true + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", + "dev": true + }, + "send": { + "version": "0.15.3", + "resolved": "https://registry.npmjs.org/send/-/send-0.15.3.tgz", + "integrity": "sha1-UBP5+ZAj31DRvZiSwZ4979HVMwk=", + "dev": true + }, + "serve-static": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.12.3.tgz", + "integrity": "sha1-n0uhni8wMMVH+K+ZEHg47DjVseI=", + "dev": true + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=", + "dev": true + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "dev": true, + "optional": true + }, + "source-map": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + "dev": true + }, + "spdx-correct": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", + "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", + "dev": true + }, + "spdx-expression-parse": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", + "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", + "dev": true + }, + "spdx-license-ids": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", + "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", + "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "dev": true, + "optional": true, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "optional": true + } + } + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", + "dev": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true + }, + "strip-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", + "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", + "dev": true + }, + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "tiny-lr": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tiny-lr/-/tiny-lr-0.2.1.tgz", + "integrity": "sha1-s/26gC5dVqM8L28QeUsy5Hescp0=", + "dev": true, + "dependencies": { + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + }, + "qs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-5.1.0.tgz", + "integrity": "sha1-TZMuXH6kEcynajEtOaYGIA/VDNk=", + "dev": true + } + } + }, + "tough-cookie": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", + "dev": true, + "optional": true + }, + "trim-newlines": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", + "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", + "dev": true + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "optional": true + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true, + "optional": true + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "dev": true + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "uglify-js": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz", + "integrity": "sha1-ZeovswWck5RpLxX+2HwrNsFrmt8=", + "dev": true, + "dependencies": { + "async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", + "dev": true + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true + }, + "underscore.string": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.2.3.tgz", + "integrity": "sha1-gGmSYzZl1eX8tNsfs6hi62jp5to=", + "dev": true + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true + }, + "uri-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/uri-path/-/uri-path-1.0.0.tgz", + "integrity": "sha1-l0fwGDWJM8Md4PzP2C0TjmcmLjI=", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "utils-merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=", + "dev": true + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "dev": true, + "optional": true + }, + "validate-npm-package-license": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", + "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", + "dev": true + }, + "vary": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz", + "integrity": "sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc=", + "dev": true + }, + "verror": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", + "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", + "dev": true, + "optional": true + }, + "websocket-driver": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.6.5.tgz", + "integrity": "sha1-XLJVbOuF9Dc8bYI4qmkchFThOjY=", + "dev": true + }, + "websocket-extensions": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.1.tgz", + "integrity": "sha1-domUmcGEtu91Q3fC27DNbLVdKec=", + "dev": true + }, + "which": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", + "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", + "dev": true + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "dependencies": { + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + } + } + } + } +} diff --git a/src/case/tree/tree.display.js b/src/case/tree/tree.display.js index d88b3ee72..030a9041d 100644 --- a/src/case/tree/tree.display.js +++ b/src/case/tree/tree.display.js @@ -44,6 +44,19 @@ BI.DisplayTree = BI.inherit(BI.TreeView, { return setting; }, + _dealWidthNodes: function (nodes) { + nodes = BI.DisplayTree.superclass._dealWidthNodes.apply(this, arguments); + var self = this, o = this.options; + BI.each(nodes, function (i, node) { + if (node.count > 0) { + node.text = node.value + "(" + BI.i18nText("BI-Basic_Altogether") + node.count + BI.i18nText("BI-Basic_Count") + ")"; + } else { + node.text = node.value; + } + }); + return nodes; + }, + initTree: function (nodes, setting) { var setting = setting || this._configSetting(); this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes); diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.js b/src/component/treevaluechooser/abstract.treevaluechooser.js index 1d929f65e..d881febe3 100644 --- a/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -227,7 +227,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { function search(parents, current, result, searched) { var newParents = BI.clone(parents); newParents.push(current); - if (self._isMatch(current, keyword)) { + if (self._isMatch(parents, current, keyword)) { searched && searched.push(newParents); return true; } @@ -256,7 +256,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { function isSearchValueInParent(parentValues) { for (var i = 0, len = parentValues.length; i < len; i++) { - if (self._isMatch(parentValues[i], keyword)) { + if (self._isMatch(parentValues.slice(0, parentValues.length - 1), parentValues[i], keyword)) { return true; } } @@ -382,7 +382,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { } function nodeSearch(deep, parentValues, current, isAllSelect, result) { - if (self._isMatch(current, keyword)) { + if (self._isMatch(parentValues, current, keyword)) { var checked = isAllSelect || isSelected(parentValues, current); createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result); return [true, checked]; @@ -612,8 +612,9 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { }); }, - _isMatch: function (value, keyword) { - var finded = BI.Func.getSearchResult([value], keyword); + _isMatch: function (parentValues, value, keyword) { + var node = this._getTreeNode(parentValues, value); + var finded = BI.Func.getSearchResult([node.text || node.value], keyword); return finded.finded.length > 0 || finded.matched.length > 0; }, diff --git a/src/css/core/utils/common.css b/src/css/core/utils/common.css index f362b482d..a4ff12fef 100644 --- a/src/css/core/utils/common.css +++ b/src/css/core/utils/common.css @@ -724,7 +724,7 @@ .bi-list-item-none:hover, .bi-list-item-none.hover { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-list-item-none:hover .bi-input, .bi-list-item-none.hover .bi-input { @@ -737,7 +737,7 @@ .bi-list-item-none:active, .bi-list-item-none.active { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-list-item-none:active .bi-input, .bi-list-item-none.active .bi-input { @@ -775,7 +775,7 @@ .bi-theme-dark .bi-list-item-none:hover, .bi-theme-dark .bi-list-item-none.hover { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-theme-dark .bi-list-item-none:hover .bi-input, .bi-theme-dark .bi-list-item-none.hover .bi-input { @@ -788,7 +788,7 @@ .bi-theme-dark .bi-list-item-none:active, .bi-theme-dark .bi-list-item-none.active { color: inherit; - background-color: inherit; + background-color: transparent; } .bi-theme-dark .bi-list-item-none:active .bi-input, .bi-theme-dark .bi-list-item-none.active .bi-input { diff --git a/src/less/core/utils/common.less b/src/less/core/utils/common.less index a81b98d5b..67e5a7bcb 100644 --- a/src/less/core/utils/common.less +++ b/src/less/core/utils/common.less @@ -706,7 +706,7 @@ & .bi-textarea { color: inherit; } - background-color: inherit; + background-color: transparent; } &:active, &.active { color: inherit; @@ -716,7 +716,7 @@ & .bi-textarea { color: inherit; } - background-color: inherit; + background-color: transparent; & .bi-high-light { color: inherit; } @@ -748,7 +748,7 @@ & .bi-textarea { color: inherit; } - background-color: inherit; + background-color: transparent; } &:active, &.active { color: inherit; @@ -758,7 +758,7 @@ & .bi-textarea { color: inherit; } - background-color: inherit; + background-color: transparent; & .bi-high-light { color: inherit; } diff --git a/src/less/resource/icon.less b/src/less/resource/icon.less index b885ea16b..d2ce74bb8 100644 --- a/src/less/resource/icon.less +++ b/src/less/resource/icon.less @@ -55,3 +55,5 @@ //Half Select .icon(check-half-select-icon, @icon-half-select); + + diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index b4096e75d..acd0f0d99 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -24,6 +24,8 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { self.trigger.getCounter().setButtonChecked(self.storeValue); }; this.storeValue = {}; + //标记正在请求数据 + this.requesting = false; this.trigger = BI.createWidget({ type: "bi.multi_select_trigger", @@ -162,10 +164,16 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { self.populate(); }); }); + //当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { //important:关闭弹出时又可能没有退出编辑状态 self.trigger.stopEditing(); - self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + } }); var triggerBtn = BI.createWidget({ @@ -218,6 +226,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { _joinKeywords: function (keywords, callback) { var self = this, o = this.options; this._assertValue(this.storeValue); + this.requesting = true; o.itemsCreator({ type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, keywords: keywords @@ -240,6 +249,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { _joinAll: function (res, callback) { var self = this, o = this.options; this._assertValue(res); + this.requesting = true; o.itemsCreator({ type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, keywords: [this.trigger.getKey()] @@ -300,6 +310,11 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { value: [] } } + if (self.wants2Quit === true) { + self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; } },