windy
8 years ago
39 changed files with 4493 additions and 1767 deletions
@ -0,0 +1,210 @@
|
||||
/** |
||||
* Created by GUY on 2017/2/8. |
||||
* |
||||
* @class BI.BubbleCombo |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.BubbleCombo = BI.inherit(BI.Widget, { |
||||
_const: { |
||||
TRIANGLE_LENGTH: 6 |
||||
}, |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-bubble-combo", |
||||
trigger: "click", |
||||
toggle: true, |
||||
direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right
|
||||
isDefaultInit: false, |
||||
isNeedAdjustHeight: true,//是否需要高度调整
|
||||
isNeedAdjustWidth: true, |
||||
stopPropagation: false, |
||||
adjustLength: 0,//调整的距离
|
||||
// adjustXOffset: 0,
|
||||
// adjustYOffset: 10,
|
||||
hideChecker: BI.emptyFn, |
||||
offsetStyle: "left", //left,right,center
|
||||
el: {}, |
||||
popup: {}, |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.BubbleCombo.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.combo = BI.createWidget({ |
||||
type: "bi.combo", |
||||
element: this, |
||||
trigger: o.trigger, |
||||
toggle: o.toggle, |
||||
direction: o.direction, |
||||
isDefaultInit: o.isDefaultInit, |
||||
isNeedAdjustHeight: o.isNeedAdjustHeight, |
||||
isNeedAdjustWidth: o.isNeedAdjustWidth, |
||||
adjustLength: this._getAdjustLength(), |
||||
stopPropagation: o.stopPropagation, |
||||
adjustXOffset: 0, |
||||
adjustYOffset: 0, |
||||
hideChecker: o.hideChecker, |
||||
offsetStyle: o.offsetStyle, |
||||
el: o.el, |
||||
popup: BI.extend({ |
||||
type: "bi.bubble_popup_view" |
||||
}, o.popup), |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_EXPAND, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { |
||||
self._showTriangle(); |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { |
||||
self._hideTriangle(); |
||||
self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); |
||||
}); |
||||
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { |
||||
self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); |
||||
}); |
||||
}, |
||||
|
||||
_getAdjustLength: function () { |
||||
return this._const.TRIANGLE_LENGTH + this.options.adjustLength; |
||||
}, |
||||
|
||||
_createTriangle: function (direction) { |
||||
var pos = {}, op = {}; |
||||
var adjustLength = this._getAdjustLength(); |
||||
switch (direction) { |
||||
case "left": |
||||
pos = { |
||||
top: 0, |
||||
bottom: 0, |
||||
left: -adjustLength |
||||
}; |
||||
op = {width: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "right": |
||||
pos = { |
||||
top: 0, |
||||
bottom: 0, |
||||
right: -adjustLength |
||||
}; |
||||
op = {width: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "top": |
||||
pos = { |
||||
left: 0, |
||||
right: 0, |
||||
top: -adjustLength |
||||
}; |
||||
op = {height: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
case "bottom": |
||||
pos = { |
||||
left: 0, |
||||
right: 0, |
||||
bottom: -adjustLength |
||||
}; |
||||
op = {height: this._const.TRIANGLE_LENGTH}; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
this.triangle = BI.createWidget(op, { |
||||
type: "bi.center_adapt", |
||||
items: [{ |
||||
type: "bi.layout", |
||||
cls: "bubble-combo-triangle-" + direction |
||||
}] |
||||
}); |
||||
pos.el = this.triangle; |
||||
BI.createWidget({ |
||||
type: "bi.absolute", |
||||
element: this, |
||||
items: [pos] |
||||
}) |
||||
}, |
||||
|
||||
_createLeftTriangle: function () { |
||||
this._createTriangle("left"); |
||||
}, |
||||
|
||||
_createRightTriangle: function () { |
||||
this._createTriangle("right"); |
||||
}, |
||||
|
||||
_createTopTriangle: function () { |
||||
this._createTriangle("top"); |
||||
}, |
||||
|
||||
_createBottomTriangle: function () { |
||||
this._createTriangle("bottom"); |
||||
}, |
||||
|
||||
_showTriangle: function () { |
||||
var pos = this.combo.getPopupPosition(); |
||||
switch (pos.dir) { |
||||
case "left,top": |
||||
case "left,bottom": |
||||
this._createLeftTriangle(); |
||||
this.combo.getView().showLine("right"); |
||||
break; |
||||
case "right,top": |
||||
case "right,bottom": |
||||
this._createRightTriangle(); |
||||
this.combo.getView().showLine("left"); |
||||
break; |
||||
case "top,left": |
||||
case "top,right": |
||||
this._createTopTriangle(); |
||||
this.combo.getView().showLine("bottom"); |
||||
break; |
||||
case "bottom,left": |
||||
case "bottom,right": |
||||
this._createBottomTriangle(); |
||||
this.combo.getView().showLine("top"); |
||||
break; |
||||
} |
||||
}, |
||||
|
||||
_hideTriangle: function () { |
||||
this.triangle && this.triangle.destroy(); |
||||
this.combo.getView().hideLine(); |
||||
}, |
||||
|
||||
hideView: function () { |
||||
this._hideTriangle(); |
||||
this.combo && this.combo.hideView(); |
||||
}, |
||||
|
||||
showView: function () { |
||||
this.combo && this.combo.showView(); |
||||
} |
||||
}); |
||||
|
||||
BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; |
||||
BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND"; |
||||
BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; |
||||
BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; |
||||
|
||||
|
||||
BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||
BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; |
||||
BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; |
||||
BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; |
||||
$.shortcut("bi.bubble_combo", BI.BubbleCombo); |
@ -0,0 +1,44 @@
|
||||
/** |
||||
* Created by GUY on 2017/2/8. |
||||
* |
||||
* @class BI.BubblePopupBarView |
||||
* @extends BI.BubblePopupView |
||||
*/ |
||||
BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.BubblePopupBarView.superclass._defaultConfig.apply(this, arguments), { |
||||
extraCls: "bi-bubble-bar-popup-view", |
||||
buttons: [{value: BI.i18nText(BI.i18nText("BI-Basic_Sure"))}, {value: BI.i18nText("BI-Basic_Cancel"), level: "ignore"}] |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.BubblePopupBarView.superclass._init.apply(this, arguments); |
||||
}, |
||||
_createToolBar: function () { |
||||
var o = this.options, self = this; |
||||
|
||||
var items = []; |
||||
BI.each(o.buttons.reverse(), function (i, buttonOpt) { |
||||
if(BI.isWidget(buttonOpt)){ |
||||
items.push(buttonOpt); |
||||
}else{ |
||||
items.push(BI.extend({ |
||||
type: 'bi.button', |
||||
height: 30, |
||||
handler: function (v) { |
||||
self.fireEvent(BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v); |
||||
} |
||||
}, buttonOpt)) |
||||
} |
||||
}); |
||||
return BI.createWidget({ |
||||
type: 'bi.right_vertical_adapt', |
||||
height: 40, |
||||
hgap: 10, |
||||
bgap: 10, |
||||
items: items |
||||
}); |
||||
} |
||||
}); |
||||
BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; |
||||
$.shortcut("bi.bubble_bar_popup_view", BI.BubblePopupBarView); |
@ -0,0 +1,73 @@
|
||||
/** |
||||
* Created by GUY on 2017/2/8. |
||||
* |
||||
* @class BI.BubblePopupView |
||||
* @extends BI.PopupView |
||||
*/ |
||||
BI.BubblePopupView = BI.inherit(BI.PopupView, { |
||||
_defaultConfig: function () { |
||||
var config = BI.BubblePopupView.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(config, { |
||||
baseCls: config.baseCls + " bi-bubble-popup-view" |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.BubblePopupView.superclass._init.apply(this, arguments); |
||||
}, |
||||
|
||||
showLine: function (direction) { |
||||
var pos = {}, op = {}; |
||||
switch (direction) { |
||||
case "left": |
||||
pos = { |
||||
top: 0, |
||||
bottom: 0, |
||||
left: -1 |
||||
}; |
||||
op = {width: 3}; |
||||
break; |
||||
case "right": |
||||
pos = { |
||||
top: 0, |
||||
bottom: 0, |
||||
right: -1 |
||||
}; |
||||
op = {width: 3}; |
||||
break; |
||||
case "top": |
||||
pos = { |
||||
left: 0, |
||||
right: 0, |
||||
top: -1 |
||||
}; |
||||
op = {height: 3}; |
||||
break; |
||||
case "bottom": |
||||
pos = { |
||||
left: 0, |
||||
right: 0, |
||||
bottom: -1 |
||||
}; |
||||
op = {height: 3}; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
this.line = BI.createWidget(op, { |
||||
type: "bi.layout", |
||||
cls: "bubble-popup-line" |
||||
}); |
||||
pos.el = this.line; |
||||
BI.createWidget({ |
||||
type: "bi.absolute", |
||||
element: this, |
||||
items: [pos] |
||||
}) |
||||
}, |
||||
|
||||
hideLine: function () { |
||||
this.line && this.line.destroy(); |
||||
} |
||||
}); |
||||
|
||||
$.shortcut("bi.bubble_popup_view", BI.BubblePopupView); |
@ -0,0 +1,242 @@
|
||||
/** |
||||
* Created by Young's on 2016/8/30. |
||||
*/ |
||||
BI.LoginTimeOut = BI.inherit(BI.BarPopoverSection, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.LoginTimeOut.superclass._defaultConfig.apply(this, arguments), {}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.LoginTimeOut.superclass._init.apply(this, arguments); |
||||
}, |
||||
|
||||
rebuildNorth: function (north) { |
||||
BI.createWidget({ |
||||
type: "bi.label", |
||||
element: north, |
||||
text: BI.i18nText("BI-Login_Timeout"), |
||||
height: 50, |
||||
textAlign: "left" |
||||
}) |
||||
}, |
||||
|
||||
rebuildCenter: function (center) { |
||||
var self = this, o = this.options; |
||||
var userNameInput = BI.createWidget({ |
||||
type: "bi.editor", |
||||
watermark: BI.i18nText("BI-Username"), |
||||
cls: "login-input", |
||||
allowBlank: true, |
||||
width: 300, |
||||
height: 30 |
||||
}); |
||||
var userNameMask = BI.createWidget({ |
||||
type: "bi.text_button", |
||||
width: 330, |
||||
height: 56, |
||||
cls: "error-mask" |
||||
}); |
||||
userNameMask.setVisible(false); |
||||
userNameMask.on(BI.TextButton.EVENT_CHANGE, function () { |
||||
userNameInput.focus(); |
||||
this.element.fadeOut(); |
||||
}); |
||||
|
||||
var userNameWrapper = BI.createWidget({ |
||||
type: "bi.absolute", |
||||
cls: "input-wrapper login-username-icon", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.icon", |
||||
width: 26, |
||||
height: 26 |
||||
}, |
||||
top: 10, |
||||
left: 0 |
||||
}, { |
||||
el: userNameInput, |
||||
top: 8, |
||||
left: 30 |
||||
}, { |
||||
el: userNameMask, |
||||
top: 0, |
||||
left: 0 |
||||
}], |
||||
width: 330, |
||||
height: 56 |
||||
}); |
||||
|
||||
|
||||
var passwordInput = BI.createWidget({ |
||||
type: "bi.editor", |
||||
inputType: "password", |
||||
cls: "login-input", |
||||
allowBlank: true, |
||||
watermark: BI.i18nText("BI-Basic_Password"), |
||||
width: 300, |
||||
height: 30 |
||||
}); |
||||
var passwordMask = BI.createWidget({ |
||||
type: "bi.text_button", |
||||
width: 330, |
||||
height: 56, |
||||
cls: "error-mask" |
||||
}); |
||||
passwordMask.setVisible(false); |
||||
passwordMask.on(BI.TextButton.EVENT_CHANGE, function () { |
||||
passwordInput.focus(); |
||||
this.element.fadeOut(); |
||||
}); |
||||
|
||||
var passwordWrapper = BI.createWidget({ |
||||
type: "bi.absolute", |
||||
cls: "input-wrapper login-password-icon", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.icon", |
||||
width: 26, |
||||
height: 26 |
||||
}, |
||||
top: 10, |
||||
left: 0 |
||||
}, { |
||||
el: passwordInput, |
||||
top: 8, |
||||
left: 30 |
||||
}, { |
||||
el: passwordMask, |
||||
top: 0, |
||||
left: 0 |
||||
}], |
||||
width: 330, |
||||
height: 56 |
||||
}); |
||||
|
||||
var loginButton = BI.createWidget({ |
||||
type: "bi.text_button", |
||||
text: BI.i18nText("BI-Basic_Login"), |
||||
cls: "login-button", |
||||
width: 330, |
||||
height: 50 |
||||
}); |
||||
loginButton.on(BI.TextButton.EVENT_CHANGE, function () { |
||||
if (BI.isEmptyString(userNameInput.getValue())) { |
||||
self._showMes(userNameMask, BI.i18nText("BI-Username_Not_Null")); |
||||
return; |
||||
} |
||||
if (BI.isEmptyString(passwordInput.getValue())) { |
||||
self._showMes(passwordMask, BI.i18nText("BI-Password_Not_Null")); |
||||
return; |
||||
} |
||||
|
||||
//反正是登录直接用FR的登录了
|
||||
FR.ajax({ |
||||
url: FR.servletURL + '?op=fs_load&cmd=login', |
||||
data: FR.cjkEncodeDO({ |
||||
fr_username: encodeURIComponent(userNameInput.getValue()), |
||||
fr_password: encodeURIComponent(passwordInput.getValue()), |
||||
fr_remember: self.keepLoginState.isSelected() |
||||
}), |
||||
type: 'POST', |
||||
async: false, |
||||
error: function () { |
||||
BI.Msg.toast("Error!"); |
||||
}, |
||||
complete: function (res, status) { |
||||
if (BI.isEmptyString(res.responseText)) { |
||||
self._showMes(userNameMask, BI.i18nText("BI-Authentication_Failed")); |
||||
return; |
||||
} |
||||
var signResult = FR.jsonDecode(res.responseText); |
||||
if (signResult.fail) { |
||||
//用户名和密码不匹配
|
||||
self._showMes(userNameMask, BI.i18nText("BI-Username_Password_Not_Correct")); |
||||
} else if (signResult.url) { |
||||
self.fireEvent(BI.LoginTimeOut.EVENT_LOGIN); |
||||
} |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var logo; |
||||
if (BI.isNotNull(window.top.FS)) { |
||||
logo = window.top.FS.config.logoImageID4FS; |
||||
} |
||||
BI.createWidget({ |
||||
type: "bi.absolute", |
||||
element: center, |
||||
cls: "bi-login-timeout-center", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.center_adapt", |
||||
items: [{ |
||||
type: "bi.img", |
||||
src: FR.servletURL + (logo ? |
||||
'?op=fr_attach&cmd=ah_image&id=' + logo + '&isAdjust=false' : |
||||
'?op=resource&resource=/com/fr/bi/web/images/login/bi_logo.png'), |
||||
width: 120, |
||||
height: 120 |
||||
}], |
||||
width: 200, |
||||
height: 300 |
||||
}, |
||||
left: 0, |
||||
top: 0 |
||||
}, { |
||||
el: userNameWrapper, |
||||
top: 30, |
||||
left: 230 |
||||
}, { |
||||
el: passwordWrapper, |
||||
top: 100, |
||||
left: 230 |
||||
}, { |
||||
el: loginButton, |
||||
top: 200, |
||||
left: 230 |
||||
}] |
||||
}); |
||||
}, |
||||
|
||||
_showMes: function (widget, mes) { |
||||
widget.setText(mes); |
||||
widget.element.fadeIn(); |
||||
setTimeout(function () { |
||||
if (widget.element.isVisible()) { |
||||
widget.element.fadeOut(); |
||||
} |
||||
}, 5000); |
||||
}, |
||||
|
||||
rebuildSouth: function (south) { |
||||
this.keepLoginState = BI.createWidget({ |
||||
type: "bi.checkbox", |
||||
width: 16, |
||||
height: 16 |
||||
}); |
||||
BI.createWidget({ |
||||
type: "bi.absolute", |
||||
element: south, |
||||
cls: "bi-login-timeout-south", |
||||
items: [{ |
||||
el: this.keepLoginState, |
||||
top: 0, |
||||
left: 230 |
||||
}, { |
||||
el: { |
||||
type: "bi.label", |
||||
text: BI.i18nText("BI-Keep_Login_State"), |
||||
cls: "keep-state", |
||||
height: 30 |
||||
}, |
||||
top: -7, |
||||
left: 260 |
||||
}] |
||||
}) |
||||
} |
||||
}); |
||||
BI.extend(BI.LoginTimeOut, { |
||||
POPOVER_ID: "___popover__id___" |
||||
}); |
||||
BI.LoginTimeOut.EVENT_LOGIN = "EVENT_LOGIN"; |
||||
$.shortcut("bi.login_timeout", BI.LoginTimeOut); |
@ -0,0 +1,163 @@
|
||||
/** |
||||
* 有总页数和总行数的分页控件 |
||||
* Created by Young's on 2016/10/13. |
||||
*/ |
||||
BI.AllCountPager = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.AllCountPager.superclass._defaultConfig.apply(this, arguments), { |
||||
extraCls: "bi-all-count-pager", |
||||
height: 30, |
||||
pages: 1, //必选项 |
||||
curr: 1, //初始化当前页, pages为数字时可用, |
||||
count: 1 //总行数 |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.AllCountPager.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.editor = BI.createWidget({ |
||||
type: "bi.small_text_editor", |
||||
cls: "pager-editor", |
||||
validationChecker: function (v) { |
||||
return (self.rowCount.getValue() == 0 && v === "0") || BI.isPositiveInteger(v); |
||||
}, |
||||
hgap: 4, |
||||
vgap: 0, |
||||
value: o.curr, |
||||
errorText: BI.i18nText("BI-Please_Input_Integer"), |
||||
width: 30, |
||||
height: 20 |
||||
}); |
||||
this.pager = BI.createWidget({ |
||||
type: "bi.detail_pager", |
||||
width: 36, |
||||
layouts: [{ |
||||
type: "bi.horizontal", |
||||
hgap: 1, |
||||
vgap: 1 |
||||
}], |
||||
|
||||
dynamicShow: false, |
||||
pages: o.pages, |
||||
curr: o.curr, |
||||
groups: 0, |
||||
|
||||
first: false, |
||||
last: false, |
||||
prev: { |
||||
type: "bi.icon_button", |
||||
value: "prev", |
||||
title: BI.i18nText("BI-Previous_Page"), |
||||
warningTitle: BI.i18nText("BI-Current_Is_First_Page"), |
||||
height: 20, |
||||
cls: "all-pager-prev column-pre-page-h-font" |
||||
}, |
||||
next: { |
||||
type: "bi.icon_button", |
||||
value: "next", |
||||
title: BI.i18nText("BI-Next_Page"), |
||||
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), |
||||
height: 20, |
||||
cls: "all-pager-next column-next-page-h-font" |
||||
}, |
||||
|
||||
hasPrev: o.hasPrev, |
||||
hasNext: o.hasNext, |
||||
firstPage: o.firstPage, |
||||
lastPage: o.lastPage |
||||
}); |
||||
|
||||
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { |
||||
self.pager.setValue(BI.parseInt(self.editor.getValue())); |
||||
self.fireEvent(BI.AllCountPager.EVENT_CHANGE); |
||||
}); |
||||
this.pager.on(BI.Pager.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.AllCountPager.EVENT_CHANGE); |
||||
}); |
||||
this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { |
||||
self.editor.setValue(self.pager.getCurrentPage()); |
||||
}); |
||||
|
||||
this.allPages = BI.createWidget({ |
||||
type: "bi.label", |
||||
width: 30, |
||||
title: o.pages, |
||||
text: "/" + o.pages |
||||
}); |
||||
|
||||
this.rowCount = BI.createWidget({ |
||||
type: "bi.label", |
||||
height: o.height, |
||||
hgap: 5, |
||||
text: o.count, |
||||
title: o.count |
||||
}); |
||||
|
||||
var count = BI.createWidget({ |
||||
type: "bi.left", |
||||
items: [{ |
||||
type: "bi.label", |
||||
height: o.height, |
||||
text: BI.i18nText("BI-Basic_Total"), |
||||
width: 15 |
||||
}, this.rowCount, { |
||||
type: "bi.label", |
||||
height: o.height, |
||||
text: BI.i18nText("BI-Basic_Tiao") + BI.i18nText("BI-Basic_Data"), |
||||
width: 50, |
||||
textAlign: "left" |
||||
}] |
||||
}); |
||||
BI.createWidget({ |
||||
type: "bi.center_adapt", |
||||
element: this, |
||||
columnSize: ["", 30, 40, 36], |
||||
items: [count, this.editor, this.allPages, this.pager] |
||||
}) |
||||
}, |
||||
|
||||
setAllPages: function (v) { |
||||
this.allPages.setText("/" + v); |
||||
this.allPages.setTitle(v); |
||||
this.pager.setAllPages(v); |
||||
this.editor.setEnable(v >= 1); |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.pager.setValue(v); |
||||
}, |
||||
|
||||
setCount: function (count) { |
||||
this.rowCount.setValue(count); |
||||
this.rowCount.setTitle(count); |
||||
}, |
||||
|
||||
getCurrentPage: function () { |
||||
return this.pager.getCurrentPage(); |
||||
}, |
||||
|
||||
hasPrev: function () { |
||||
return this.pager.hasPrev(); |
||||
}, |
||||
|
||||
hasNext: function () { |
||||
return this.pager.hasNext(); |
||||
}, |
||||
|
||||
setPagerVisible: function (b) { |
||||
this.editor.setVisible(b); |
||||
this.allPages.setVisible(b); |
||||
this.pager.setVisible(b); |
||||
}, |
||||
|
||||
getAliasWidth: function () { |
||||
return this.options.width - 100; |
||||
}, |
||||
|
||||
populate: function () { |
||||
this.pager.populate(); |
||||
} |
||||
}); |
||||
BI.AllCountPager.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
$.shortcut("bi.all_count_pager", BI.AllCountPager); |
@ -0,0 +1,288 @@
|
||||
/** |
||||
* 分页控件 |
||||
* |
||||
* Created by GUY on 2015/8/31. |
||||
* @class BI.DetailPager |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.DetailPager = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.DetailPager.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-detail-pager", |
||||
behaviors: {}, |
||||
layouts: [{ |
||||
type: "bi.horizontal", |
||||
hgap: 10, |
||||
vgap: 0 |
||||
}], |
||||
|
||||
dynamicShow: true, //是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态
|
||||
//dynamicShow为false时以下两个有用
|
||||
dynamicShowFirstLast: false,//是否动态显示首页、尾页
|
||||
dynamicShowPrevNext: false,//是否动态显示上一页、下一页
|
||||
pages: false, //总页数
|
||||
curr: function () { |
||||
return 1; |
||||
}, //初始化当前页
|
||||
groups: 0, //连续显示分页数
|
||||
jump: BI.emptyFn, //分页的回调函数
|
||||
|
||||
first: false, //是否显示首页
|
||||
last: false, //是否显示尾页
|
||||
prev: "上一页", |
||||
next: "下一页", |
||||
|
||||
firstPage: 1, |
||||
lastPage: function () { //在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法
|
||||
return 1; |
||||
}, |
||||
hasPrev: BI.emptyFn, //pages不可用时有效
|
||||
hasNext: BI.emptyFn //pages不可用时有效
|
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.DetailPager.superclass._init.apply(this, arguments); |
||||
var self = this; |
||||
this.currPage = BI.result(this.options, "curr"); |
||||
//翻页太灵敏
|
||||
this._lock = false; |
||||
this._debouce = BI.debounce(function () { |
||||
self._lock = false; |
||||
}, 300); |
||||
this._populate(); |
||||
}, |
||||
|
||||
_populate: function () { |
||||
var self = this, o = this.options, view = [], dict = {}; |
||||
this.empty(); |
||||
var pages = BI.result(o, "pages"); |
||||
var curr = BI.result(this, "currPage"); |
||||
var groups = BI.result(o, "groups"); |
||||
var first = BI.result(o, "first"); |
||||
var last = BI.result(o, "last"); |
||||
var prev = BI.result(o, "prev"); |
||||
var next = BI.result(o, "next"); |
||||
|
||||
if (pages === false) { |
||||
groups = 0; |
||||
first = false; |
||||
last = false; |
||||
} else { |
||||
groups > pages && (groups = pages); |
||||
} |
||||
|
||||
//计算当前组
|
||||
dict.index = Math.ceil((curr + ((groups > 1 && groups !== pages) ? 1 : 0)) / (groups === 0 ? 1 : groups)); |
||||
|
||||
//当前页非首页,则输出上一页
|
||||
if (((!o.dynamicShow && !o.dynamicShowPrevNext) || curr > 1) && prev !== false) { |
||||
if (BI.isKey(prev)) { |
||||
view.push({ |
||||
text: prev, |
||||
value: "prev", |
||||
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) |
||||
}) |
||||
} else { |
||||
view.push(BI.extend({ |
||||
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) |
||||
}, prev)); |
||||
} |
||||
} |
||||
|
||||
//当前组非首组,则输出首页
|
||||
if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (dict.index > 1 && groups !== 0)) && first) { |
||||
view.push({ |
||||
text: first, |
||||
value: "first", |
||||
disabled: !(dict.index > 1 && groups !== 0) |
||||
}); |
||||
if (dict.index > 1 && groups !== 0) { |
||||
view.push({ |
||||
type: "bi.label", |
||||
cls: "page-ellipsis", |
||||
text: "\u2026" |
||||
}); |
||||
} |
||||
} |
||||
|
||||
//输出当前页组
|
||||
dict.poor = Math.floor((groups - 1) / 2); |
||||
dict.start = dict.index > 1 ? curr - dict.poor : 1; |
||||
dict.end = dict.index > 1 ? (function () { |
||||
var max = curr + (groups - dict.poor - 1); |
||||
return max > pages ? pages : max; |
||||
}()) : groups; |
||||
if (dict.end - dict.start < groups - 1) { //最后一组状态
|
||||
dict.start = dict.end - groups + 1; |
||||
} |
||||
var s = dict.start, e = dict.end; |
||||
if (first && last && (dict.index > 1 && groups !== 0) && (pages > groups && dict.end < pages && groups !== 0)) { |
||||
s++; |
||||
e--; |
||||
} |
||||
for (; s <= e; s++) { |
||||
if (s === curr) { |
||||
view.push({ |
||||
text: s, |
||||
value: s, |
||||
selected: true |
||||
}) |
||||
} else { |
||||
view.push({ |
||||
text: s, |
||||
value: s |
||||
}) |
||||
} |
||||
} |
||||
|
||||
//总页数大于连续分页数,且当前组最大页小于总页,输出尾页
|
||||
if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) { |
||||
if (pages > groups && dict.end < pages && groups !== 0) { |
||||
view.push({ |
||||
type: "bi.label", |
||||
cls: "page-ellipsis", |
||||
text: "\u2026" |
||||
}); |
||||
} |
||||
view.push({ |
||||
text: last, |
||||
value: "last", |
||||
disabled: !(pages > groups && dict.end < pages && groups !== 0) |
||||
}) |
||||
} |
||||
|
||||
//当前页不为尾页时,输出下一页
|
||||
dict.flow = !prev && groups === 0; |
||||
if (((!o.dynamicShow && !o.dynamicShowPrevNext) && next) || (curr !== pages && next || dict.flow)) { |
||||
view.push((function () { |
||||
if (BI.isKey(next)) { |
||||
if (pages === false) { |
||||
return {text: next, value: "next", disabled: o.hasNext(curr) === false} |
||||
} |
||||
return (dict.flow && curr === pages) |
||||
? |
||||
{text: next, value: "next", disabled: true} |
||||
: |
||||
{text: next, value: "next", disabled: !(curr !== pages && next || dict.flow)}; |
||||
} else { |
||||
return BI.extend({ |
||||
disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) |
||||
}, next); |
||||
} |
||||
}())); |
||||
} |
||||
|
||||
this.button_group = BI.createWidget({ |
||||
type: "bi.button_group", |
||||
element: this, |
||||
items: BI.createItems(view, { |
||||
cls: "page-item", |
||||
height: 23, |
||||
hgap: 10 |
||||
}), |
||||
behaviors: o.behaviors, |
||||
layouts: o.layouts |
||||
}); |
||||
this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { |
||||
if (self._lock === true) { |
||||
return; |
||||
} |
||||
self._lock = true; |
||||
self._debouce(); |
||||
if (type === BI.Events.CLICK) { |
||||
var v = self.button_group.getValue()[0]; |
||||
switch (v) { |
||||
case "first": |
||||
self.currPage = 1; |
||||
break; |
||||
case "last": |
||||
self.currPage = pages; |
||||
break; |
||||
case "prev": |
||||
self.currPage--; |
||||
break; |
||||
case "next": |
||||
self.currPage++; |
||||
break; |
||||
default: |
||||
self.currPage = v; |
||||
break; |
||||
} |
||||
o.jump.apply(self, [{ |
||||
pages: pages, |
||||
curr: self.currPage |
||||
}]); |
||||
self._populate(); |
||||
self.fireEvent(BI.DetailPager.EVENT_CHANGE, obj); |
||||
} |
||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
||||
}); |
||||
this.fireEvent(BI.DetailPager.EVENT_AFTER_POPULATE); |
||||
}, |
||||
|
||||
getCurrentPage: function () { |
||||
return this.currPage; |
||||
}, |
||||
|
||||
setAllPages: function (pages) { |
||||
this.options.pages = pages; |
||||
}, |
||||
|
||||
hasPrev: function (v) { |
||||
v || (v = 1); |
||||
var o = this.options; |
||||
var pages = this.options.pages; |
||||
return pages === false ? o.hasPrev(v) : v > 1; |
||||
}, |
||||
|
||||
hasNext: function (v) { |
||||
v || (v = 1); |
||||
var o = this.options; |
||||
var pages = this.options.pages; |
||||
return pages === false ? o.hasNext(v) : v < pages; |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
var o = this.options; |
||||
v = v | 0; |
||||
v = v < 1 ? 1 : v; |
||||
if (o.pages === false) { |
||||
var lastPage = BI.result(o, "lastPage"), firstPage = 1; |
||||
this.currPage = v > lastPage ? lastPage : ((firstPage = BI.result(o, "firstPage")), (v < firstPage ? firstPage : v)); |
||||
} else { |
||||
v = v > o.pages ? o.pages : v; |
||||
this.currPage = v; |
||||
} |
||||
this._populate(); |
||||
}, |
||||
|
||||
getValue: function () { |
||||
var val = this.button_group.getValue()[0]; |
||||
switch (val) { |
||||
case "prev": |
||||
return -1; |
||||
case "next": |
||||
return 1; |
||||
case "first": |
||||
return BI.MIN; |
||||
case "last": |
||||
return BI.MAX; |
||||
default : |
||||
return val; |
||||
} |
||||
}, |
||||
|
||||
attr: function (key, value) { |
||||
BI.DetailPager.superclass.attr.apply(this, arguments); |
||||
if (key === "curr") { |
||||
this.currPage = BI.result(this.options, "curr"); |
||||
} |
||||
}, |
||||
|
||||
populate: function () { |
||||
this._populate(); |
||||
} |
||||
}); |
||||
BI.DetailPager.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.DetailPager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE"; |
||||
$.shortcut("bi.detail_pager", BI.DetailPager); |
@ -1,116 +0,0 @@
|
||||
/** |
||||
* 显示页码的分页控件 |
||||
* |
||||
* Created by GUY on 2016/2/17. |
||||
* @class BI.NumberPager |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.NumberPager = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.NumberPager.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-number-pager", |
||||
width: 95, |
||||
height: 25, |
||||
pages: false, //总页数
|
||||
curr: 1, //初始化当前页, pages为数字时可用
|
||||
|
||||
hasPrev: BI.emptyFn, |
||||
hasNext: BI.emptyFn, |
||||
firstPage: 1, |
||||
lastPage: BI.emptyFn |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.NumberPager.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.currentPage = o.curr; |
||||
this.label = BI.createWidget({ |
||||
type: "bi.label", |
||||
height: o.height - 2, |
||||
value: this.currentPage |
||||
}); |
||||
this.pager = BI.createWidget({ |
||||
type: "bi.pager", |
||||
width: 36, |
||||
layouts: [{ |
||||
type: "bi.horizontal", |
||||
hgap: 1, |
||||
vgap: 1 |
||||
}], |
||||
|
||||
dynamicShow: false, |
||||
pages: o.pages, |
||||
curr: o.curr, |
||||
groups: 0, |
||||
|
||||
first: false, |
||||
last: false, |
||||
prev: { |
||||
type: "bi.icon_button", |
||||
value: "prev", |
||||
title: BI.i18nText("BI-Previous_Page"), |
||||
warningTitle: BI.i18nText("BI-Current_Is_First_Page"), |
||||
height: o.height - 2, |
||||
iconWidth: o.height - 2, |
||||
iconHeight: o.height - 2, |
||||
cls: "number-pager-prev column-pre-page-h-font" |
||||
}, |
||||
next: { |
||||
type: "bi.icon_button", |
||||
value: "next", |
||||
title: BI.i18nText("BI-Next_Page"), |
||||
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), |
||||
height: o.height - 2, |
||||
iconWidth: o.height - 2, |
||||
iconHeight: o.height - 2, |
||||
cls: "number-pager-next column-next-page-h-font" |
||||
}, |
||||
|
||||
hasPrev: o.hasPrev, |
||||
hasNext: o.hasNext, |
||||
firstPage: o.firstPage, |
||||
lastPage: o.lastPage |
||||
}); |
||||
|
||||
this.pager.on(BI.Pager.EVENT_CHANGE, function () { |
||||
if (self.getCurrentPage() !== self.pager.getCurrentPage()) { |
||||
self.currentPage = self.pager.getCurrentPage(); |
||||
self.fireEvent(BI.NumberPager.EVENT_CHANGE); |
||||
} |
||||
}); |
||||
this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { |
||||
self.label.setValue(self.pager.getCurrentPage()); |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.center_adapt", |
||||
element: this, |
||||
columnSize: [20, "", 20, 36], |
||||
items: [{type: "bi.label", text: "第"}, this.label, {type: "bi.label", text: "页"}, this.pager] |
||||
}) |
||||
}, |
||||
|
||||
getCurrentPage: function () { |
||||
return this.currentPage; |
||||
}, |
||||
|
||||
hasPrev: function () { |
||||
return this.pager.hasPrev(); |
||||
}, |
||||
|
||||
hasNext: function () { |
||||
return this.pager.hasNext(); |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
this.currentPage = v; |
||||
this.pager.setValue(v); |
||||
}, |
||||
|
||||
populate: function () { |
||||
this.pager.populate(); |
||||
} |
||||
}); |
||||
BI.NumberPager.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
$.shortcut("bi.number_pager", BI.NumberPager); |
@ -1,112 +0,0 @@
|
||||
/** |
||||
* 可以跳转的分页控件 |
||||
* |
||||
* Created by GUY on 2015/9/8. |
||||
* @class BI.SkipPager |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.SkipPager = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.SkipPager.superclass._defaultConfig.apply(this, arguments), { |
||||
extraCls: "bi-skip-pager", |
||||
width: 110, |
||||
height: 25, |
||||
pages: false, //总页数
|
||||
curr: 1, //初始化当前页, pages为数字时可用
|
||||
|
||||
hasPrev: BI.emptyFn, |
||||
hasNext: BI.emptyFn, |
||||
firstPage: 1, |
||||
lastPage: BI.emptyFn |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.SkipPager.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
this.currentPage = o.curr; |
||||
this.editor = BI.createWidget({ |
||||
type: "bi.small_text_editor", |
||||
validationChecker: function (v) { |
||||
return BI.isPositiveInteger(v); |
||||
}, |
||||
hgap: 4, |
||||
vgap: 0, |
||||
value: o.curr, |
||||
errorText: BI.i18nText("BI-Please_Input_Integer"), |
||||
width: 30, |
||||
height: o.height - 2 |
||||
}); |
||||
this.pager = BI.createWidget({ |
||||
type: "bi.pager", |
||||
layouts: [{ |
||||
type: "bi.horizontal", |
||||
hgap: 1, |
||||
vgap: 1 |
||||
}], |
||||
|
||||
dynamicShow: false, |
||||
pages: o.pages, |
||||
curr: o.curr, |
||||
groups: 0, |
||||
|
||||
first: false, |
||||
last: false, |
||||
prev: { |
||||
type: "bi.icon_button", |
||||
value: "prev", |
||||
title: BI.i18nText("BI-Previous_Page"), |
||||
warningTitle: BI.i18nText("BI-Current_Is_First_Page"), |
||||
height: o.height - 2, |
||||
cls: "number-pager-prev column-pre-page-h-font" |
||||
}, |
||||
next: { |
||||
type: "bi.icon_button", |
||||
value: "next", |
||||
title: BI.i18nText("BI-Next_Page"), |
||||
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), |
||||
height: o.height - 2, |
||||
cls: "number-pager-next column-next-page-h-font" |
||||
}, |
||||
|
||||
hasPrev: o.hasPrev, |
||||
hasNext: o.hasNext, |
||||
firstPage: o.firstPage, |
||||
lastPage: o.lastPage |
||||
}); |
||||
|
||||
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { |
||||
self.pager.setValue(self.editor.getValue()); |
||||
}); |
||||
this.pager.on(BI.Pager.EVENT_CHANGE, function () { |
||||
if (self.getCurrentPage() !== self.pager.getCurrentPage()) { |
||||
self.currentPage = self.pager.getCurrentPage(); |
||||
self.fireEvent(BI.SkipPager.EVENT_CHANGE); |
||||
} |
||||
}); |
||||
this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { |
||||
self.editor.setValue(self.pager.getCurrentPage()); |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
type: "bi.center_adapt", |
||||
element: this, |
||||
items: [{type: "bi.label", text: "第"}, this.editor, {type: "bi.label", text: "页"}, this.pager] |
||||
}) |
||||
}, |
||||
|
||||
getCurrentPage: function () { |
||||
return this.currentPage; |
||||
}, |
||||
|
||||
setValue: function(v){ |
||||
this.currentPage = v; |
||||
this.pager.setValue(v); |
||||
}, |
||||
|
||||
populate: function () { |
||||
this.pager.populate(); |
||||
} |
||||
}); |
||||
BI.SkipPager.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
$.shortcut("bi.skip_pager", BI.SkipPager); |
@ -0,0 +1,235 @@
|
||||
/** |
||||
* 自适应宽度的表格 |
||||
* |
||||
* Created by GUY on 2016/2/3. |
||||
* @class BI.AdaptiveTable |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.AdaptiveTable = BI.inherit(BI.Widget, { |
||||
|
||||
_const: { |
||||
perColumnSize: 100 |
||||
}, |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.AdaptiveTable.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-adaptive-table", |
||||
el: { |
||||
type: "bi.resizable_table" |
||||
}, |
||||
isNeedResize: true, |
||||
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.AdaptiveTable.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
|
||||
var data = this._digest(); |
||||
this.table = BI.createWidget(o.el, { |
||||
type: "bi.resizable_table", |
||||
element: this, |
||||
width: o.width, |
||||
height: o.height, |
||||
isNeedResize: o.isNeedResize, |
||||
isResizeAdapt: false, |
||||
|
||||
isNeedFreeze: o.isNeedFreeze, |
||||
freezeCols: data.freezeCols, |
||||
|
||||
isNeedMerge: o.isNeedMerge, |
||||
mergeCols: o.mergeCols, |
||||
mergeRule: o.mergeRule, |
||||
|
||||
columnSize: data.columnSize, |
||||
|
||||
headerRowSize: o.headerRowSize, |
||||
rowSize: o.rowSize, |
||||
|
||||
regionColumnSize: data.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(); |
||||
self._populate(); |
||||
self.table.populate(); |
||||
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); |
||||
}); |
||||
|
||||
this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { |
||||
o.columnSize = this.getColumnSize(); |
||||
self._populate(); |
||||
self.table.populate(); |
||||
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); |
||||
}); |
||||
}, |
||||
|
||||
_getFreezeColLength: function () { |
||||
return this.options.isNeedFreeze === true ? this.options.freezeCols.length : 0; |
||||
}, |
||||
|
||||
_digest: function () { |
||||
var o = this.options; |
||||
var columnSize = o.columnSize.slice(); |
||||
var regionColumnSize = o.regionColumnSize.slice(); |
||||
var freezeCols = o.freezeCols.slice(); |
||||
var regionSize = o.regionColumnSize[0]; |
||||
var freezeColLength = this._getFreezeColLength(); |
||||
if (!regionSize || regionSize > o.width - 10 || regionSize < 10) { |
||||
regionSize = (freezeColLength > o.columnSize.length / 2 ? 2 / 3 : 1 / 3) * o.width; |
||||
} |
||||
if (freezeColLength === 0) { |
||||
regionSize = 0; |
||||
} |
||||
if (freezeCols.length >= columnSize.length) { |
||||
freezeCols = []; |
||||
} |
||||
if (!BI.isNumber(columnSize[0])) { |
||||
columnSize = o.minColumnSize; |
||||
} |
||||
var summaryFreezeColumnSize = 0, summaryColumnSize = 0; |
||||
BI.each(columnSize, function (i, size) { |
||||
if (i < freezeColLength) { |
||||
summaryFreezeColumnSize += size; |
||||
} |
||||
summaryColumnSize += size; |
||||
}); |
||||
if (freezeColLength > 0) { |
||||
columnSize[freezeColLength - 1] = BI.clamp(regionSize - (summaryFreezeColumnSize - columnSize[freezeColLength - 1]), |
||||
o.minColumnSize[freezeColLength - 1] || 10, o.maxColumnSize[freezeColLength - 1] || Number.MAX_VALUE); |
||||
} |
||||
if (columnSize.length > 0) { |
||||
columnSize[columnSize.length - 1] = BI.clamp(o.width - BI.GridTableScrollbar.SIZE - regionSize - (summaryColumnSize - summaryFreezeColumnSize - columnSize[columnSize.length - 1]), |
||||
o.minColumnSize[columnSize.length - 1] || 10, o.maxColumnSize[columnSize.length - 1] || Number.MAX_VALUE); |
||||
} |
||||
regionColumnSize[0] = regionSize; |
||||
|
||||
return { |
||||
freezeCols: freezeCols, |
||||
columnSize: columnSize, |
||||
regionColumnSize: regionColumnSize |
||||
} |
||||
}, |
||||
|
||||
_populate: function () { |
||||
var o = this.options; |
||||
var data = this._digest(); |
||||
o.regionColumnSize = data.regionColumnSize; |
||||
o.columnSize = data.columnSize; |
||||
this.table.setColumnSize(data.columnSize); |
||||
this.table.setRegionColumnSize(data.regionColumnSize); |
||||
this.table.attr("freezeCols", data.freezeCols); |
||||
}, |
||||
|
||||
setWidth: function (width) { |
||||
BI.AdaptiveTable.superclass.setWidth.apply(this, arguments); |
||||
this.table.setWidth(width); |
||||
}, |
||||
|
||||
setHeight: function (height) { |
||||
BI.AdaptiveTable.superclass.setHeight.apply(this, arguments); |
||||
this.table.setHeight(height); |
||||
}, |
||||
|
||||
setColumnSize: function (columnSize) { |
||||
this.options.columnSize = columnSize; |
||||
}, |
||||
|
||||
getColumnSize: function () { |
||||
return this.table.getColumnSize(); |
||||
}, |
||||
|
||||
setRegionColumnSize: function (regionColumnSize) { |
||||
this.options.regionColumnSize = regionColumnSize; |
||||
}, |
||||
|
||||
getRegionColumnSize: function () { |
||||
return this.table.getRegionColumnSize(); |
||||
}, |
||||
|
||||
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(); |
||||
}, |
||||
|
||||
attr: function (key, value) { |
||||
var v = BI.AdaptiveTable.superclass.attr.apply(this, arguments); |
||||
if (key === "freezeCols") { |
||||
return v; |
||||
} |
||||
return this.table.attr.apply(this.table, arguments); |
||||
}, |
||||
|
||||
restore: function () { |
||||
this.table.restore(); |
||||
}, |
||||
|
||||
populate: function (items) { |
||||
var self = this, o = this.options; |
||||
this._populate(); |
||||
this.table.populate.apply(this.table, arguments); |
||||
}, |
||||
|
||||
destroy: function () { |
||||
this.table.destroy(); |
||||
BI.AdaptiveTable.superclass.destroy.apply(this, arguments); |
||||
} |
||||
}); |
||||
$.shortcut('bi.adaptive_table', BI.AdaptiveTable); |
@ -1,32 +0,0 @@
|
||||
/** |
||||
* Created by GUY on 2016/5/7. |
||||
* @class BI.LayerTreeTableCell |
||||
* @extends BI.Single |
||||
*/ |
||||
BI.LayerTreeTableCell = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.LayerTreeTableCell.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-layer-tree-table-cell", |
||||
layer: 0, |
||||
text: "" |
||||
}) |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.LayerTreeTableCell.superclass._init.apply(this, arguments); |
||||
var o = this.options; |
||||
BI.createWidget({ |
||||
type: "bi.label", |
||||
element: this, |
||||
textAlign: "left", |
||||
whiteSpace: "nowrap", |
||||
height: o.height, |
||||
text: o.text, |
||||
value: o.value, |
||||
lgap: 5 + 30 * o.layer, |
||||
rgap: 5 |
||||
}) |
||||
} |
||||
}); |
||||
|
||||
$.shortcut("bi.layer_tree_table_cell", BI.LayerTreeTableCell); |
@ -0,0 +1,46 @@
|
||||
/** |
||||
* |
||||
* Created by GUY on 2016/5/26. |
||||
* @class BI.TableStyleCell |
||||
* @extends BI.Single |
||||
*/ |
||||
BI.TableStyleCell = BI.inherit(BI.Single, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.TableStyleCell.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-table-style-cell", |
||||
styleGetter: BI.emptyFn |
||||
}); |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.TableStyleCell.superclass._init.apply(this, arguments); |
||||
var o = this.options; |
||||
this.text = BI.createWidget({ |
||||
type: "bi.label", |
||||
element: this, |
||||
textAlign: "left", |
||||
forceCenter: true, |
||||
hgap: 5, |
||||
text: o.text |
||||
}); |
||||
this._digestStyle(); |
||||
}, |
||||
|
||||
_digestStyle: function () { |
||||
var o = this.options; |
||||
var style = o.styleGetter(); |
||||
if (style) { |
||||
this.text.element.css(style); |
||||
} |
||||
}, |
||||
|
||||
setText: function (text) { |
||||
this.text.setText(text); |
||||
}, |
||||
|
||||
populate: function () { |
||||
this._digestStyle(); |
||||
} |
||||
}); |
||||
$.shortcut('bi.table_style_cell', BI.TableStyleCell); |
@ -0,0 +1,330 @@
|
||||
/** |
||||
* |
||||
* 树状结构的表格 |
||||
* |
||||
* Created by GUY on 2015/9/22. |
||||
* @class BI.TableTree |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.TableTree = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.TableTree.superclass._defaultConfig.apply(this, arguments), { |
||||
baseCls: "bi-table-tree", |
||||
el: { |
||||
type: "bi.resizable_table" |
||||
}, |
||||
isNeedResize: true,//是否需要调整列宽
|
||||
isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化
|
||||
|
||||
freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效
|
||||
|
||||
isNeedMerge: true,//是否需要合并单元格
|
||||
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: [] |
||||
}) |
||||
}, |
||||
|
||||
_getVDeep: function () { |
||||
return this.options.crossHeader.length;//纵向深度
|
||||
}, |
||||
|
||||
_getHDeep: function () { |
||||
var o = this.options; |
||||
return Math.max(o.mergeCols.length, o.freezeCols.length, BI.TableTree.maxDeep(o.items) - 1); |
||||
}, |
||||
|
||||
_init: function () { |
||||
BI.TableTree.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
var data = this._digest(); |
||||
this.table = BI.createWidget(o.el, { |
||||
type: "bi.resizable_table", |
||||
element: this, |
||||
width: 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: data.header, |
||||
items: data.items |
||||
}); |
||||
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); |
||||
}); |
||||
}, |
||||
|
||||
_digest: function () { |
||||
var self = this, o = this.options; |
||||
var deep = this._getHDeep(); |
||||
var vDeep = this._getVDeep(); |
||||
var header = BI.TableTree.formatHeader(o.header, o.crossHeader, o.crossItems, deep, vDeep, o.headerCellStyleGetter); |
||||
var items = BI.TableTree.formatItems(o.items, deep, false, o.summaryCellStyleGetter); |
||||
return { |
||||
header: header, |
||||
items: items |
||||
} |
||||
}, |
||||
|
||||
setWidth: function (width) { |
||||
BI.TableTree.superclass.setWidth.apply(this, arguments); |
||||
this.table.setWidth(width); |
||||
}, |
||||
|
||||
setHeight: function (height) { |
||||
BI.TableTree.superclass.setHeight.apply(this, arguments); |
||||
this.table.setHeight(height); |
||||
}, |
||||
|
||||
setColumnSize: function (columnSize) { |
||||
this.options.columnSize = columnSize; |
||||
this.table.setColumnSize(columnSize); |
||||
}, |
||||
|
||||
getColumnSize: function () { |
||||
return this.table.getColumnSize(); |
||||
}, |
||||
|
||||
setRegionColumnSize: function (columnSize) { |
||||
this.options.regionColumnSize = columnSize; |
||||
this.table.setRegionColumnSize(columnSize); |
||||
}, |
||||
|
||||
getRegionColumnSize: function () { |
||||
return this.table.getRegionColumnSize(); |
||||
}, |
||||
|
||||
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(); |
||||
}, |
||||
|
||||
attr: function () { |
||||
BI.TableTree.superclass.attr.apply(this, arguments); |
||||
this.table.attr.apply(this.table, arguments); |
||||
}, |
||||
|
||||
restore: function () { |
||||
this.table.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; |
||||
} |
||||
var data = this._digest(); |
||||
this.table.populate(data.items, data.header); |
||||
}, |
||||
|
||||
destroy: function () { |
||||
this.table.destroy(); |
||||
BI.TableTree.superclass.destroy.apply(this, arguments); |
||||
} |
||||
}); |
||||
|
||||
BI.extend(BI.TableTree, { |
||||
formatHeader: function (header, crossHeader, crossItems, hDeep, vDeep, styleGetter) { |
||||
var items = BI.TableTree.formatCrossItems(crossItems, vDeep, styleGetter); |
||||
var result = []; |
||||
for (var i = 0; i < vDeep; i++) { |
||||
var c = []; |
||||
for (var j = 0; j < hDeep; j++) { |
||||
c.push(crossHeader[i]); |
||||
} |
||||
result.push(c.concat(items[i] || [])); |
||||
} |
||||
if (header && header.length > 0) { |
||||
result.push(header); |
||||
} |
||||
return result; |
||||
}, |
||||
|
||||
formatItems: function (nodes, deep, isCross, styleGetter) { |
||||
var self = this; |
||||
var result = []; |
||||
|
||||
function track(store, node) { |
||||
var next; |
||||
if (BI.isArray(node.children)) { |
||||
BI.each(node.children, function (index, child) { |
||||
var next; |
||||
if (store != -1) { |
||||
next = store.slice(); |
||||
next.push(node); |
||||
} else { |
||||
next = []; |
||||
} |
||||
track(next, child); |
||||
}); |
||||
if (store != -1) { |
||||
next = store.slice(); |
||||
next.push(node); |
||||
} else { |
||||
next = []; |
||||
} |
||||
if (/**(store == -1 || node.children.length > 1) &&**/ BI.isNotEmptyArray(node.values)) { |
||||
var summary = { |
||||
text: BI.i18nText("BI-Summary_Values"), |
||||
type: "bi.table_style_cell", |
||||
styleGetter: function () { |
||||
return styleGetter(store === -1) |
||||
} |
||||
}; |
||||
for (var i = next.length; i < deep; i++) { |
||||
next.push(summary); |
||||
} |
||||
if (!isCross) { |
||||
next = next.concat(node.values); |
||||
} |
||||
if (next.length > 0) { |
||||
if (!isCross) { |
||||
result.push(next); |
||||
} else { |
||||
for (var k = 0, l = node.values.length; k < l; k++) { |
||||
result.push(next); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return; |
||||
} |
||||
if (store != -1) { |
||||
next = store.slice(); |
||||
for (var i = next.length; i < deep; i++) { |
||||
next.push(node); |
||||
} |
||||
} else { |
||||
next = []; |
||||
} |
||||
if (!isCross && BI.isArray(node.values)) { |
||||
next = next.concat(node.values); |
||||
} |
||||
if (isCross && BI.isArray(node.values)) { |
||||
for (var i = 0, len = node.values.length; i < len - 1; i++) { |
||||
if (next.length > 0) { |
||||
result.push(next); |
||||
} |
||||
} |
||||
} |
||||
if (next.length > 0) { |
||||
result.push(next); |
||||
} |
||||
} |
||||
|
||||
BI.each(nodes, function (i, node) { |
||||
track(-1, node); |
||||
}); |
||||
//填充空位
|
||||
BI.each(result, function (i, line) { |
||||
var last = BI.last(line); |
||||
for (var j = line.length; j < deep; j++) { |
||||
line.push(last); |
||||
} |
||||
}); |
||||
return result; |
||||
}, |
||||
|
||||
formatCrossItems: function (nodes, deep, styleGetter) { |
||||
var items = BI.TableTree.formatItems(nodes, deep, true, styleGetter); |
||||
return BI.unzip(items); |
||||
}, |
||||
|
||||
maxDeep: function (nodes) { |
||||
function track(deep, node) { |
||||
var d = deep; |
||||
if (BI.isNotEmptyArray(node.children)) { |
||||
BI.each(node.children, function (index, child) { |
||||
d = Math.max(d, track(deep + 1, child)); |
||||
}); |
||||
} |
||||
return d; |
||||
} |
||||
|
||||
var deep = 1; |
||||
if (BI.isObject(nodes)) { |
||||
BI.each(nodes, function (i, node) { |
||||
deep = Math.max(deep, track(1, node)); |
||||
}); |
||||
} |
||||
return deep; |
||||
} |
||||
}); |
||||
|
||||
$.shortcut("bi.table_tree", BI.TableTree); |
@ -1,92 +0,0 @@
|
||||
/** |
||||
* 分页table |
||||
* |
||||
* Created by GUY on 2015/9/8. |
||||
* @class BI.Tabler |
||||
* @extends BI.Widget |
||||
*/ |
||||
BI.Tabler = BI.inherit(BI.Widget, { |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.Tabler.superclass._defaultConfig.apply(this, arguments), { |
||||
extraCls: "bi-tabler", |
||||
|
||||
pager: {}, |
||||
|
||||
layouts: [{ |
||||
type: "bi.float_center_adapt" |
||||
}], |
||||
|
||||
tabler: { |
||||
isNeedFreeze: false,//是否需要冻结单元格
|
||||
freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效
|
||||
|
||||
isNeedMerge: true,//是否需要合并单元格
|
||||
|
||||
mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
|
||||
return BI.isEqual(row1, row2); |
||||
}, |
||||
|
||||
columnSize: [], |
||||
rowSize: 37, |
||||
header: [], |
||||
items: [], |
||||
|
||||
//交叉表头
|
||||
crossHeader: [], |
||||
crossItems: [] |
||||
} |
||||
}) |
||||
}, |
||||
_init: function () { |
||||
BI.Tabler.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
|
||||
this.pager = BI.createWidget(o.pager, { |
||||
type: "bi.pager" |
||||
}); |
||||
var creater = BI.createWidget({ |
||||
type: "bi.button_tree", |
||||
items: [{ |
||||
el: this.pager |
||||
}], |
||||
layouts: o.layouts |
||||
}) |
||||
this.pager.on(BI.Controller.EVENT_CHANGE, function (type) { |
||||
if (type === BI.Events.CLICK) { |
||||
self.fireEvent(BI.Tabler.EVENT_CHANGE); |
||||
} |
||||
}); |
||||
this.container = BI.createWidget({ |
||||
type: "bi.layout" |
||||
}) |
||||
BI.createWidget({ |
||||
type: "bi.vtape", |
||||
element: this, |
||||
items: [{ |
||||
el: this.container |
||||
}, { |
||||
el: creater, |
||||
height: 40 |
||||
}] |
||||
}); |
||||
this.populate(); |
||||
}, |
||||
|
||||
getCurrentPage: function () { |
||||
return this.pager.getValue(); |
||||
}, |
||||
|
||||
populate: function (opt) { |
||||
var o = this.options; |
||||
this.container.empty(); |
||||
|
||||
BI.extend(o.tabler, opt); |
||||
this.table = BI.createWidget(this.options.tabler, { |
||||
type: "bi.table_tree", |
||||
element: this.container |
||||
}); |
||||
} |
||||
}); |
||||
BI.Tabler.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
$.shortcut("bi.tabler", BI.Tabler); |
Loading…
Reference in new issue