Browse Source

no message

es6
刘荣歆 7 years ago
parent
commit
6a09622386
  1. 638
      bi/widget.js
  2. 3
      demo/css/main.css
  3. 4
      demo/js/config/widget.js
  4. 44
      demo/js/widget/dailertest/alldateWidget.js
  5. 119
      demo/js/widget/dailertest/demo.test_editor.js
  6. 4
      demo/less/main.less
  7. 57374
      docs/core.js.orig
  8. 3
      docs/demo.css
  9. 230
      docs/demo.js
  10. 638
      docs/widget.js
  11. 94
      src/widget/dailertest/combo.datetime.js
  12. 123
      src/widget/dailertest/popup.date_time.js
  13. 154
      src/widget/dailertest/timetunning.js
  14. 152
      src/widget/dailertest/tuningnumbereditor.js
  15. 5
      src/widget/date/calendar/popup.calendar.date.js
  16. 3
      src/widget/date/combo.date.js

638
bi/widget.js

@ -2334,6 +2334,525 @@ BI.BranchRelation = BI.inherit(BI.Widget, {
});
BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE";
BI.shortcut("bi.branch_relation", BI.BranchRelation);/**
* Created by dailer on 2017/7/19.
* 日期时间练习
*/
BI.DateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
selectedTime: {
year: 2017,
month: 0,
day: 1,
hour: 0,
minute: 0,
second: 0
},
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_time_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
}
})
},
_reviseMinute: function () {
this.m._finetuning(this.s.isNeedRevise);
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.isNeedRevise);
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue())
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
}
});
BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);/**
* Created by GUY on 2015/9/7.
* @class BI.DateCalendarPopup
* @extends BI.Widget
*/
BI.DateTimePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.DateTimePopup.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.DateTimePopup.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.timeTunning = BI.createWidget({
type: "bi.time_tunning"
});
this.buttons = BI.createWidget({
type: "bi.button_group",
items: [{
type: "bi.text_button",
text: BI.i18nText('BI-Basic_Clears')
}, {
type: "bi.text_button",
text: BI.i18nText("BI-Basic_Sure")
}],
chooseType: 0,
behaviors: {},
layouts: [{
type: "bi.center_adapt"
}]
});
this.dateTime = BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.calendar, this.timeTunning, this.buttons]
});
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.DateTimePopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.date_time_popup", BI.DateTimePopup);/**
* Created by dailer on 2017/7/19.
* 时间微调器练习
*/
BI.TimeTuning = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
disabled: false,
currentTime: {
hour: 0,
minute: 0,
second: 0
}
})
},
_init: function () {
BI.TimeTuning.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
if (o.formatter == BI.emptyFn) {
this.formatter = function (v) {
return v;
}
} else {
this.formatter = o.formatter;
}
this.parser = o.parser;
this.step = o.step;
this.min = o.min;
this.max = o.max;
this.currentTime = BI.deepClone(o.currentTime);
this.last = {
lastH: o.currentTime.hour,
lastM: o.currentTime.minute,
lastS: o.currentTime.second
}
//时
this.h = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.hour,
min: 0,
max: 23,
width: 60,
height: 30
});
this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {});
//分
this.m = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.minute,
min: 0,
max: 59,
width: 60,
height: 30
})
this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseHour();
});
//秒
this.s = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.second,
min: 0,
max: 59,
width: 60,
height: 30
})
this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseMinute();
});
this.editor = BI.createWidget({
type: "bi.horizontal",
items: [{
type: "bi.label",
text: "时间",
width: 45,
height: 30
},
this.h,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.m,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.s
]
});
BI.createWidget({
type: "bi.htape",
cls: "bi-border demo-clolor",
element: this,
items: [this.editor],
width: 270,
height: 50
});
},
_reviseMinute: function () {
this.m._finetuning(this.s.isNeedRevise);
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.isNeedRevise);
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue())
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue();
}
});
BI.TimeTuning.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.time_tunning", BI.TimeTuning);/**
* Created by dailer on 2017/7/18.
* 数值微调器练习
*/
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: 0,
disabled: false,
min: 0,
max: 100000,
step: 1,
formatter: BI.emptyFn,
parser: BI.emptyFn
})
},
_init: function () {
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
if (o.formatter == BI.emptyFn) {
this.formatter = function (v) {
return v;
}
} else {
this.formatter = o.formatter;
}
this.parser = o.parser;
this.step = o.step;
this.min = o.min;
this.max = o.max;
this.value = o.value;
this.isNeedRevise = 0;
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: o.value,
errorText: BI.i18nText("BI-Please_Input_Natural_Number")
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () {
self.setValue(self.editor.getValue());
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._isNeedRevise();
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
}]
});
},
//微调
_finetuning: function (add) {
//窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法
var v = BI.parseFloat(this.editor.getValue()) * 1000000000000;
var addend = add * this.step * 1000000000000;
var result = (v + addend) / 1000000000000;
if (result > this.max) {
this.editor.setValue(this.formatter(this.min));
this.isNeedRevise = 1;
this.value = this.min;
return;
}
if (result < this.min) {
this.editor.setValue(this.formatter(this.max));
this.isNeedRevise = -1;
this.value = this.max;
return;
}
this.value = result;
this.isNeedRevise = 0;
this.editor.setValue(this.formatter(result));
},
_isNeedRevise: function () {
// console.log(this.editor.getValue() - this.value);
},
getMinAndMax: function () {
return {
min: this.min,
max: this.max
};
},
getStep: function () {
return this.step;
},
getValue: function () {
return this.value;
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue(this.formatter(v));
}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.test_editor", BI.FineTuningNumberEditor);/**
* 日期控件中的月份下拉框
*
* Created by GUY on 2015/9/7.
@ -2613,12 +3132,13 @@ BI.DateCalendarPopup = BI.inherit(BI.Widget, {
month: date.month,
day: this.selectedTime.day
});
return calendar;
return calendar
},
_init: function () {
BI.DateCalendarPopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var self = this,
o = this.options;
this.today = new Date();
this._year = this.today.getFullYear();
this._month = this.today.getMonth();
@ -2764,7 +3284,8 @@ BI.DateCombo = BI.inherit(BI.Widget, {
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_trigger"
@ -14523,117 +15044,6 @@ BI.SwitchTree.SelectType = {
};
BI.shortcut('bi.switch_tree', BI.SwitchTree);
/**
* Created by dailer on 2017/7/18.
* 数值微调器练习
*/
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: 0,
disabled: false,
min: 0,
max: 100,
step: 1,
formatter: BI.emptyFn,
parser: BI.emptyFn
})
},
_init: function () {
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.formatter = o.formatter;
this.step = this.options.step;
console.log(this.options.value);
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: o.value,
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(1);
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",
handler: 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",
handler: 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
}]
});
},
//微调
_finetuning: function (add) {
//窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法
var v = BI.parseFloat(this.editor.getValue()) * 1000000000000;
var addend = add * this.step * 1000000000000;
var result = (v + addend) / 1000000000000;
console.log(this.options.formatter.toString());
this.editor.setValue(this.formatter(result));
},
getMinAndMax: function () {},
getStep: function () {},
getValue: function () {},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.test_editor", BI.FineTuningNumberEditor);/**
* 年份下拉框
*
* Created by GUY on 2015/8/28.

3
demo/css/main.css

@ -48,3 +48,6 @@ body {
.demo-editor {
border: 1px solid #cccccc;
}
.demo-clolor {
color: #1a1a1a;
}

4
demo/js/config/widget.js

@ -253,5 +253,9 @@ Demo.WIDGET_CONFIG = [{
id: 7,
text: '数值微调器',
value: "demo.test_editor"
}, {
id: 8,
text: '所有日期控件',
value: "demo.all_date_widget"
}
];

44
demo/js/widget/dailertest/alldateWidget.js

@ -0,0 +1,44 @@
/**
* 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.date_picker",
width: 300
}, {
type: "bi.date_trigger",
width: 300
}, {
type: "bi.date_calendar_popup",
width: 300
}, {
type: "bi.date_triangle_trigger",
width: 300
}, {
type: "bi.calendar",
logic: {
dynamic: true
},
width: 300
}]
}
}
})
BI.shortcut("demo.all_date_widget", Demo.Date);

119
demo/js/widget/dailertest/demo.test_editor.js

@ -0,0 +1,119 @@
/**
* Created by Dailer on 2017/7/18.
*/
Demo.TestEditor = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var editor = BI.createWidget({
type: "bi.sign_editor",
cls: "bi-border",
width: 90,
height: 28,
});
var test = BI.createWidget({
type: "bi.test_editor",
// formatter: function (v) {
// return v + "%";
// },
value: 12,
width: 90,
height: 28,
step: 1
});
var timetunning = BI.createWidget({
type: "bi.time_tunning",
currentTime: {
hour: 13,
minute: 45,
second: 50
}
});
var dateTimeCombo = BI.createWidget({
type: "bi.date_time_combo",
width: 300
});
var enable = 1;
return {
type: "bi.horizontal_auto",
items: [{
el: test
},
{
type: "bi.left",
items: [{
el: editor
}, {
type: "bi.button",
text: "设置step",
width: 90,
height: 28,
handler: function () {
test.setStep(editor.getValue());
BI.Msg.toast("设置成功")
},
lgap: 5
}, {
type: "bi.button",
text: "toggle disabled",
height: 28,
handler: function () {
enable *= -1;
test.setEnable(Boolean(1 + enable));
BI.Msg.toast("设置成功")
},
lgap: 20
}]
},
{
type: "bi.left",
items: [
timetunning,
{
type: "bi.label",
text: "时间选择控件,自动进位与退位,返回数据自动对小于10的数补0",
whiteSpace: "normal",
cls: "layout-bg3",
height: 50,
width: 400,
lgap: 10
}
],
},
{
type: "bi.left",
items: [{
type: "bi.button",
text: "getCurrentTime",
cls: "layout-bg1",
handler: function () {
BI.Msg.alert("JSON 形式", JSON.stringify(timetunning.getCurrentTime()));
}
}, {
type: "bi.button",
text: "getCurrentTimeStr",
cls: "layout-bg1",
handler: function () {
BI.Msg.alert("字符串形式", timetunning.getCurrentTimeStr());
}
}],
hgap: 10
},
{
type: "bi.left",
items: [dateTimeCombo]
}
],
vgap: 20,
hgap: 10
}
}
});
BI.shortcut("demo.test_editor", Demo.TestEditor);

4
demo/less/main.less

@ -64,3 +64,7 @@ body {
.demo-editor {
border: 1px solid rgb(204, 204, 204);
}
.demo-clolor {
color: #1a1a1a;
}

57374
docs/core.js.orig

File diff suppressed because it is too large Load Diff

3
docs/demo.css

@ -51,6 +51,9 @@ body {
.demo-editor {
border: 1px solid #cccccc;
}
.demo-clolor {
color: #1a1a1a;
}
.demo-north {
background-color: #3c8dbc;
}

230
docs/demo.js

@ -3592,6 +3592,10 @@ Demo.COMPONENT_CONFIG = [{
id: 7,
text: '数值微调器',
value: "demo.test_editor"
}, {
id: 8,
text: '所有日期控件',
value: "demo.all_date_widget"
}
];Demo.Func = BI.inherit(BI.Widget, {
props: {
@ -6557,6 +6561,167 @@ Demo.Date = BI.inherit(BI.Widget, {
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.date_picker",
width: 300
}, {
type: "bi.date_trigger",
width: 300
}, {
type: "bi.date_calendar_popup",
width: 300
}, {
type: "bi.date_triangle_trigger",
width: 300
}, {
type: "bi.calendar",
logic: {
dynamic: true
},
width: 300
}]
}
}
})
BI.shortcut("demo.all_date_widget", Demo.Date);/**
* Created by Dailer on 2017/7/18.
*/
Demo.TestEditor = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var editor = BI.createWidget({
type: "bi.sign_editor",
cls: "bi-border",
width: 90,
height: 28,
});
var test = BI.createWidget({
type: "bi.test_editor",
// formatter: function (v) {
// return v + "%";
// },
value: 12,
width: 90,
height: 28,
step: 1
});
var timetunning = BI.createWidget({
type: "bi.time_tunning",
currentTime: {
hour: 13,
minute: 45,
second: 50
}
});
var dateTimeCombo = BI.createWidget({
type: "bi.date_time_combo",
width: 300
});
var enable = 1;
return {
type: "bi.horizontal_auto",
items: [{
el: test
},
{
type: "bi.left",
items: [{
el: editor
}, {
type: "bi.button",
text: "设置step",
width: 90,
height: 28,
handler: function () {
test.setStep(editor.getValue());
BI.Msg.toast("设置成功")
},
lgap: 5
}, {
type: "bi.button",
text: "toggle disabled",
height: 28,
handler: function () {
enable *= -1;
test.setEnable(Boolean(1 + enable));
BI.Msg.toast("设置成功")
},
lgap: 20
}]
},
{
type: "bi.left",
items: [
timetunning,
{
type: "bi.label",
text: "时间选择控件,自动进位与退位,返回数据自动对小于10的数补0",
whiteSpace: "normal",
cls: "layout-bg3",
height: 50,
width: 400,
lgap: 10
}
],
},
{
type: "bi.left",
items: [{
type: "bi.button",
text: "getCurrentTime",
cls: "layout-bg1",
handler: function () {
BI.Msg.alert("JSON 形式", JSON.stringify(timetunning.getCurrentTime()));
}
}, {
type: "bi.button",
text: "getCurrentTimeStr",
cls: "layout-bg1",
handler: function () {
BI.Msg.alert("字符串形式", timetunning.getCurrentTimeStr());
}
}],
hgap: 10
},
{
type: "bi.left",
items: [dateTimeCombo]
}
],
vgap: 20,
hgap: 10
}
}
});
BI.shortcut("demo.test_editor", Demo.TestEditor);/**
* 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 {
@ -9303,71 +9468,6 @@ BI.shortcut("demo.responsive_table", Demo.Func);Demo.Func = BI.inherit(BI.Widget
}
});
BI.shortcut("demo.sequence_table", Demo.Func);/**
* Created by Dailer on 2017/7/18.
*/
Demo.TestEditor = BI.inherit(BI.Widget, {
props: {
baseCls: ""
},
render: function () {
var editor = BI.createWidget({
type: "bi.sign_editor",
cls: "bi-border",
formatter: function (v) {
return 20;
},
width: 90,
height: 28,
});
var test = BI.createWidget({
type: "bi.test_editor",
value: 12,
width: 90,
height: 28,
step: 0.1
});
var enable = 1;
return {
type: "bi.vertical",
items: [{
el: test
}, {
type: "bi.left",
items: [{
el: editor
}, {
type: "bi.button",
text: "设置step",
width: 90,
height: 28,
handler: function () {
test.setStep(editor.getValue());
BI.Msg.toast("设置成功")
}
}, {
type: "bi.button",
text: "toggle disabled",
height: 28,
handler: function () {
enable *= -1;
test.setEnable(Boolean(1 + enable));
BI.Msg.toast("设置成功")
},
lgap: 20
}]
},
],
vgap: 20,
hgap: 10
}
}
})
BI.shortcut("demo.test_editor", Demo.TestEditor);/**
* Created by Dailer on 2017/7/13.
*/
Demo.TimeInterval = BI.inherit(BI.Widget, {

638
docs/widget.js

@ -2334,6 +2334,525 @@ BI.BranchRelation = BI.inherit(BI.Widget, {
});
BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE";
BI.shortcut("bi.branch_relation", BI.BranchRelation);/**
* Created by dailer on 2017/7/19.
* 日期时间练习
*/
BI.DateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
selectedTime: {
year: 2017,
month: 0,
day: 1,
hour: 0,
minute: 0,
second: 0
},
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_time_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
}
})
},
_reviseMinute: function () {
this.m._finetuning(this.s.isNeedRevise);
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.isNeedRevise);
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue())
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
}
});
BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);/**
* Created by GUY on 2015/9/7.
* @class BI.DateCalendarPopup
* @extends BI.Widget
*/
BI.DateTimePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.DateTimePopup.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.DateTimePopup.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.timeTunning = BI.createWidget({
type: "bi.time_tunning"
});
this.buttons = BI.createWidget({
type: "bi.button_group",
items: [{
type: "bi.text_button",
text: BI.i18nText('BI-Basic_Clears')
}, {
type: "bi.text_button",
text: BI.i18nText("BI-Basic_Sure")
}],
chooseType: 0,
behaviors: {},
layouts: [{
type: "bi.center_adapt"
}]
});
this.dateTime = BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.calendar, this.timeTunning, this.buttons]
});
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.DateTimePopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.date_time_popup", BI.DateTimePopup);/**
* Created by dailer on 2017/7/19.
* 时间微调器练习
*/
BI.TimeTuning = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
disabled: false,
currentTime: {
hour: 0,
minute: 0,
second: 0
}
})
},
_init: function () {
BI.TimeTuning.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
if (o.formatter == BI.emptyFn) {
this.formatter = function (v) {
return v;
}
} else {
this.formatter = o.formatter;
}
this.parser = o.parser;
this.step = o.step;
this.min = o.min;
this.max = o.max;
this.currentTime = BI.deepClone(o.currentTime);
this.last = {
lastH: o.currentTime.hour,
lastM: o.currentTime.minute,
lastS: o.currentTime.second
}
//时
this.h = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.hour,
min: 0,
max: 23,
width: 60,
height: 30
});
this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {});
//分
this.m = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.minute,
min: 0,
max: 59,
width: 60,
height: 30
})
this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseHour();
});
//秒
this.s = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.second,
min: 0,
max: 59,
width: 60,
height: 30
})
this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseMinute();
});
this.editor = BI.createWidget({
type: "bi.horizontal",
items: [{
type: "bi.label",
text: "时间",
width: 45,
height: 30
},
this.h,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.m,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.s
]
});
BI.createWidget({
type: "bi.htape",
cls: "bi-border demo-clolor",
element: this,
items: [this.editor],
width: 270,
height: 50
});
},
_reviseMinute: function () {
this.m._finetuning(this.s.isNeedRevise);
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.isNeedRevise);
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue())
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue();
}
});
BI.TimeTuning.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.time_tunning", BI.TimeTuning);/**
* Created by dailer on 2017/7/18.
* 数值微调器练习
*/
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: 0,
disabled: false,
min: 0,
max: 100000,
step: 1,
formatter: BI.emptyFn,
parser: BI.emptyFn
})
},
_init: function () {
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
if (o.formatter == BI.emptyFn) {
this.formatter = function (v) {
return v;
}
} else {
this.formatter = o.formatter;
}
this.parser = o.parser;
this.step = o.step;
this.min = o.min;
this.max = o.max;
this.value = o.value;
this.isNeedRevise = 0;
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: o.value,
errorText: BI.i18nText("BI-Please_Input_Natural_Number")
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () {
self.setValue(self.editor.getValue());
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._isNeedRevise();
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
}]
});
},
//微调
_finetuning: function (add) {
//窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法
var v = BI.parseFloat(this.editor.getValue()) * 1000000000000;
var addend = add * this.step * 1000000000000;
var result = (v + addend) / 1000000000000;
if (result > this.max) {
this.editor.setValue(this.formatter(this.min));
this.isNeedRevise = 1;
this.value = this.min;
return;
}
if (result < this.min) {
this.editor.setValue(this.formatter(this.max));
this.isNeedRevise = -1;
this.value = this.max;
return;
}
this.value = result;
this.isNeedRevise = 0;
this.editor.setValue(this.formatter(result));
},
_isNeedRevise: function () {
// console.log(this.editor.getValue() - this.value);
},
getMinAndMax: function () {
return {
min: this.min,
max: this.max
};
},
getStep: function () {
return this.step;
},
getValue: function () {
return this.value;
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue(this.formatter(v));
}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.test_editor", BI.FineTuningNumberEditor);/**
* 日期控件中的月份下拉框
*
* Created by GUY on 2015/9/7.
@ -2613,12 +3132,13 @@ BI.DateCalendarPopup = BI.inherit(BI.Widget, {
month: date.month,
day: this.selectedTime.day
});
return calendar;
return calendar
},
_init: function () {
BI.DateCalendarPopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var self = this,
o = this.options;
this.today = new Date();
this._year = this.today.getFullYear();
this._month = this.today.getMonth();
@ -2764,7 +3284,8 @@ BI.DateCombo = BI.inherit(BI.Widget, {
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_trigger"
@ -14523,117 +15044,6 @@ BI.SwitchTree.SelectType = {
};
BI.shortcut('bi.switch_tree', BI.SwitchTree);
/**
* Created by dailer on 2017/7/18.
* 数值微调器练习
*/
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: 0,
disabled: false,
min: 0,
max: 100,
step: 1,
formatter: BI.emptyFn,
parser: BI.emptyFn
})
},
_init: function () {
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.formatter = o.formatter;
this.step = this.options.step;
console.log(this.options.value);
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: o.value,
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(1);
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",
handler: 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",
handler: 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
}]
});
},
//微调
_finetuning: function (add) {
//窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法
var v = BI.parseFloat(this.editor.getValue()) * 1000000000000;
var addend = add * this.step * 1000000000000;
var result = (v + addend) / 1000000000000;
console.log(this.options.formatter.toString());
this.editor.setValue(this.formatter(result));
},
getMinAndMax: function () {},
getStep: function () {},
getValue: function () {},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.test_editor", BI.FineTuningNumberEditor);/**
* 年份下拉框
*
* Created by GUY on 2015/8/28.

94
src/widget/dailertest/combo.datetime.js

@ -0,0 +1,94 @@
/**
* Created by dailer on 2017/7/19.
* 日期时间练习
*/
BI.DateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
selectedTime: {
year: 2017,
month: 0,
day: 1,
hour: 0,
minute: 0,
second: 0
},
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_time_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
}
})
},
_reviseMinute: function () {
this.m._finetuning(this.s.isNeedRevise);
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.isNeedRevise);
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue())
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
}
});
BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);

123
src/widget/dailertest/popup.date_time.js

@ -0,0 +1,123 @@
/**
* Created by GUY on 2015/9/7.
* @class BI.DateCalendarPopup
* @extends BI.Widget
*/
BI.DateTimePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.DateTimePopup.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.DateTimePopup.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.timeTunning = BI.createWidget({
type: "bi.time_tunning"
});
this.buttons = BI.createWidget({
type: "bi.button_group",
items: [{
type: "bi.text_button",
text: BI.i18nText('BI-Basic_Clears')
}, {
type: "bi.text_button",
text: BI.i18nText("BI-Basic_Sure")
}],
chooseType: 0,
behaviors: {},
layouts: [{
type: "bi.center_adapt"
}]
});
this.dateTime = BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.calendar, this.timeTunning, this.buttons]
});
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.DateTimePopup.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.date_time_popup", BI.DateTimePopup);

154
src/widget/dailertest/timetunning.js

@ -0,0 +1,154 @@
/**
* Created by dailer on 2017/7/19.
* 时间微调器练习
*/
BI.TimeTuning = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
disabled: false,
currentTime: {
hour: 0,
minute: 0,
second: 0
}
})
},
_init: function () {
BI.TimeTuning.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
if (o.formatter == BI.emptyFn) {
this.formatter = function (v) {
return v;
}
} else {
this.formatter = o.formatter;
}
this.parser = o.parser;
this.step = o.step;
this.min = o.min;
this.max = o.max;
this.currentTime = BI.deepClone(o.currentTime);
this.last = {
lastH: o.currentTime.hour,
lastM: o.currentTime.minute,
lastS: o.currentTime.second
}
//时
this.h = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.hour,
min: 0,
max: 23,
width: 60,
height: 30
});
this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {});
//分
this.m = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.minute,
min: 0,
max: 59,
width: 60,
height: 30
})
this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseHour();
});
//秒
this.s = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.second,
min: 0,
max: 59,
width: 60,
height: 30
})
this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseMinute();
});
this.editor = BI.createWidget({
type: "bi.horizontal",
items: [{
type: "bi.label",
text: "时间",
width: 45,
height: 30
},
this.h,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.m,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.s
]
});
BI.createWidget({
type: "bi.htape",
cls: "bi-border demo-clolor",
element: this,
items: [this.editor],
width: 270,
height: 50
});
},
_reviseMinute: function () {
this.m._finetuning(this.s.isNeedRevise);
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.isNeedRevise);
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue())
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue();
}
});
BI.TimeTuning.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.time_tunning", BI.TimeTuning);

152
src/widget/dailertest/tuningnumbereditor.js

@ -0,0 +1,152 @@
/**
* Created by dailer on 2017/7/18.
* 数值微调器练习
*/
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: 0,
disabled: false,
min: 0,
max: 100000,
step: 1,
formatter: BI.emptyFn,
parser: BI.emptyFn
})
},
_init: function () {
BI.FineTuningNumberEditor.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
if (o.formatter == BI.emptyFn) {
this.formatter = function (v) {
return v;
}
} else {
this.formatter = o.formatter;
}
this.parser = o.parser;
this.step = o.step;
this.min = o.min;
this.max = o.max;
this.value = o.value;
this.isNeedRevise = 0;
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: o.value,
errorText: BI.i18nText("BI-Please_Input_Natural_Number")
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () {
self.setValue(self.editor.getValue());
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._isNeedRevise();
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
}]
});
},
//微调
_finetuning: function (add) {
//窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法
var v = BI.parseFloat(this.editor.getValue()) * 1000000000000;
var addend = add * this.step * 1000000000000;
var result = (v + addend) / 1000000000000;
if (result > this.max) {
this.editor.setValue(this.formatter(this.min));
this.isNeedRevise = 1;
this.value = this.min;
return;
}
if (result < this.min) {
this.editor.setValue(this.formatter(this.max));
this.isNeedRevise = -1;
this.value = this.max;
return;
}
this.value = result;
this.isNeedRevise = 0;
this.editor.setValue(this.formatter(result));
},
_isNeedRevise: function () {
// console.log(this.editor.getValue() - this.value);
},
getMinAndMax: function () {
return {
min: this.min,
max: this.max
};
},
getStep: function () {
return this.step;
},
getValue: function () {
return this.value;
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue(this.formatter(v));
}
});
BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.test_editor", BI.FineTuningNumberEditor);

5
src/widget/date/calendar/popup.calendar.date.js

@ -27,12 +27,13 @@ BI.DateCalendarPopup = BI.inherit(BI.Widget, {
month: date.month,
day: this.selectedTime.day
});
return calendar;
return calendar
},
_init: function () {
BI.DateCalendarPopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var self = this,
o = this.options;
this.today = new Date();
this._year = this.today.getFullYear();
this._month = this.today.getMonth();

3
src/widget/date/combo.date.js

@ -14,7 +14,8 @@ BI.DateCombo = BI.inherit(BI.Widget, {
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_trigger"

Loading…
Cancel
Save