fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.2 KiB

/**
* 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), {
8 years ago
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",
8 years ago
trigger: "lclick,",
8 years ago
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",
8 years ago
trigger: "lclick,",
8 years ago
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));
8 years ago
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";
8 years ago
BI.shortcut("bi.fine_tuning_number_editor", BI.FineTuningNumberEditor);