Browse Source

Pull request #1380: DEC-13767 fix: 修复date_picker最大值最小值判断问题

Merge in VISUAL/fineui from ~FRANK.QIU/fineui:master to master

* commit '0009a3bcb73bc01aada324de55a7f3c764c01604':
  DEC-13767 fix: 修复date_picker最大值最小值判断问题
master
Frank.Qiu 5 years ago
parent
commit
0041ca443f
  1. 1
      changelog.md
  2. 57
      src/widget/date/calendar/picker.date.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志 # 更新日志
2.0(2020-07) 2.0(2020-07)
- 修复date_picker最大值最小值判断问题
- 复选下拉树和下拉列表添加showView和hideVIew方法 - 复选下拉树和下拉列表添加showView和hideVIew方法
- number_editor支持自动检测数值与范围是否合法 - number_editor支持自动检测数值与范围是否合法
- 修复了颜色选择器设置值为null的时候,trigger和popup表现不一致的问题 - 修复了颜色选择器设置值为null的时候,trigger和popup表现不一致的问题

57
src/widget/date/calendar/picker.date.js

@ -6,35 +6,36 @@
BI.DatePicker = BI.inherit(BI.Widget, { BI.DatePicker = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments); var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: "bi-date-picker", baseCls: "bi-date-picker",
height: 40, height: 40,
min: "1900-01-01", // 最小日期 min: "1900-01-01", // 最小日期
max: "2099-12-31" // 最大日期 max: "2099-12-31", // 最大日期
}); });
}, },
_init: function () { _init: function () {
BI.DatePicker.superclass._init.apply(this, arguments); BI.DatePicker.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this; var o = this.options;
this._year = BI.getDate().getFullYear(); this._year = BI.getDate().getFullYear();
this._month = BI.getDate().getMonth() + 1; this._month = BI.getDate().getMonth() + 1;
this.left = BI.createWidget({ this.left = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "pre-page-h-font", cls: "pre-page-h-font",
width: 24, width: 24,
height: 24 height: 24,
}); });
this.left.on(BI.IconButton.EVENT_CHANGE, function () { this.left.on(BI.IconButton.EVENT_CHANGE, function () {
if (self._month === 1) { if (self._month === 1) {
self.setValue({ self.setValue({
year: self.year.getValue() - 1, year: self.year.getValue() - 1,
month: 12 month: 12,
}); });
} else { } else {
self.setValue({ self.setValue({
year: self.year.getValue(), year: self.year.getValue(),
month: self.month.getValue() - 1 month: self.month.getValue() - 1,
}); });
} }
self.fireEvent(BI.DatePicker.EVENT_CHANGE); self.fireEvent(BI.DatePicker.EVENT_CHANGE);
@ -46,19 +47,19 @@ BI.DatePicker = BI.inherit(BI.Widget, {
type: "bi.icon_button", type: "bi.icon_button",
cls: "next-page-h-font", cls: "next-page-h-font",
width: 24, width: 24,
height: 24 height: 24,
}); });
this.right.on(BI.IconButton.EVENT_CHANGE, function () { this.right.on(BI.IconButton.EVENT_CHANGE, function () {
if (self._month === 12) { if (self._month === 12) {
self.setValue({ self.setValue({
year: self.year.getValue() + 1, year: self.year.getValue() + 1,
month: 1 month: 1,
}); });
} else { } else {
self.setValue({ self.setValue({
year: self.year.getValue(), year: self.year.getValue(),
month: self.month.getValue() + 1 month: self.month.getValue() + 1,
}); });
} }
self.fireEvent(BI.DatePicker.EVENT_CHANGE); self.fireEvent(BI.DatePicker.EVENT_CHANGE);
@ -70,23 +71,23 @@ BI.DatePicker = BI.inherit(BI.Widget, {
type: "bi.year_date_combo", type: "bi.year_date_combo",
behaviors: o.behaviors, behaviors: o.behaviors,
min: o.min, min: o.min,
max: o.max max: o.max,
}); });
this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () { this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () {
self.setValue({ self.setValue({
year: self.year.getValue(), year: self.year.getValue(),
month: self.month.getValue() month: self.month.getValue(),
}); });
self.fireEvent(BI.DatePicker.EVENT_CHANGE); self.fireEvent(BI.DatePicker.EVENT_CHANGE);
}); });
this.month = BI.createWidget({ this.month = BI.createWidget({
type: "bi.month_date_combo", type: "bi.month_date_combo",
behaviors: o.behaviors behaviors: o.behaviors,
}); });
this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () { this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () {
self.setValue({ self.setValue({
year: self.year.getValue(), year: self.year.getValue(),
month: self.month.getValue() month: self.month.getValue(),
}); });
self.fireEvent(BI.DatePicker.EVENT_CHANGE); self.fireEvent(BI.DatePicker.EVENT_CHANGE);
}); });
@ -97,9 +98,9 @@ BI.DatePicker = BI.inherit(BI.Widget, {
items: [{ items: [{
el: { el: {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.left] items: [this.left],
}, },
width: 24 width: 24,
}, { }, {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [{ items: [{
@ -109,35 +110,39 @@ BI.DatePicker = BI.inherit(BI.Widget, {
rgap: 10, rgap: 10,
items: [{ items: [{
el: this.year, el: this.year,
lgap: 10 lgap: 10,
}, this.month] }, this.month],
} },
}] }],
}, { }, {
el: { el: {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.right] items: [this.right],
}, },
width: 24 width: 24,
}] }],
}); });
this.setValue({ this.setValue({
year: this._year, year: this._year,
month: this._month month: this._month,
}); });
}, },
_checkLeftValid: function () { _checkLeftValid: function () {
var o = this.options; var o = this.options;
var valid = !(this._month === 1 && this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); var minDate = BI.parseDateTime(o.min, "%Y-%X-%d");
var valid = !(this._month <= (minDate.getMonth() + 1) && this._year <= minDate.getFullYear());
this.left.setEnable(valid); this.left.setEnable(valid);
return valid; return valid;
}, },
_checkRightValid: function () { _checkRightValid: function () {
var o = this.options; var o = this.options;
var valid = !(this._month === 12 && this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); var maxDate = BI.parseDateTime(o.max, "%Y-%X-%d");
var valid = !(this._month >= (maxDate.getMonth() + 1) && this._year >= maxDate.getFullYear());
this.right.setEnable(valid); this.right.setEnable(valid);
return valid; return valid;
}, },
@ -161,9 +166,9 @@ BI.DatePicker = BI.inherit(BI.Widget, {
getValue: function () { getValue: function () {
return { return {
year: this.year.getValue(), year: this.year.getValue(),
month: this.month.getValue() month: this.month.getValue(),
}; };
} },
}); });
BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE"; BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.date_picker", BI.DatePicker); BI.shortcut("bi.date_picker", BI.DatePicker);
Loading…
Cancel
Save