Browse Source

BI-79930 日期类型控件全系列可设置最大最小日期

es6
windy 4 years ago
parent
commit
e4c64fe83d
  1. 1
      changelog.md
  2. 6
      i18n/i18n.cn.js
  3. 6
      src/core/platform/web/dom.js
  4. 30
      src/widget/datepane/card.static.datepane.js
  5. 17
      src/widget/datepane/datepane.js
  6. 30
      src/widget/datetimepane/card.static.datetimepane.js
  7. 16
      src/widget/datetimepane/datetimepane.js
  8. 97
      src/widget/dynamicdate/dynamicdate.card.js
  9. 21
      src/widget/dynamicdate/dynamicdate.param.item.js
  10. 8
      src/widget/dynamicdate/dynamicdate.popup.js
  11. 2
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  12. 4
      src/widget/dynamicdatetime/dynamicdatetime.popup.js
  13. 17
      src/widget/timeinterval/dateinterval.js
  14. 17
      src/widget/timeinterval/timeinterval.js
  15. 32
      src/widget/year/card.dynamic.year.js
  16. 32
      src/widget/year/card.year.js
  17. 28
      src/widget/year/combo.year.js
  18. 18
      src/widget/year/popup.year.js
  19. 12
      src/widget/year/trigger.year.js
  20. 50
      src/widget/yearmonth/card.dynamic.yearmonth.js
  21. 1
      src/widget/yearmonth/card.static.yearmonth.js
  22. 16
      src/widget/yearmonth/combo.yearmonth.js
  23. 8
      src/widget/yearmonth/popup.yearmonth.js
  24. 14
      src/widget/yearmonth/trigger.yearmonth.js
  25. 17
      src/widget/yearmonthinterval/yearmonthinterval.js
  26. 50
      src/widget/yearquarter/card.dynamic.yearquarter.js
  27. 42
      src/widget/yearquarter/card.static.yearquarter.js
  28. 28
      src/widget/yearquarter/combo.yearquarter.js
  29. 18
      src/widget/yearquarter/popup.yearquarter.js
  30. 14
      src/widget/yearquarter/trigger.yearquarter.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志 # 更新日志
2.0(2021-01) 2.0(2021-01)
- 日期类型控件全系列可设置最大最小日期
- 调整了combo的popup显示位置计算逻辑 - 调整了combo的popup显示位置计算逻辑
2.0(2020-12) 2.0(2020-12)

6
i18n/i18n.cn.js

@ -189,5 +189,9 @@ BI.i18n = {
"BI-Basic_Quarter": "季度", "BI-Basic_Quarter": "季度",
"BI-Basic_No_Select": "不选", "BI-Basic_No_Select": "不选",
"BI-Basic_Now": "此刻", "BI-Basic_Now": "此刻",
"BI-Color_Picker_Error_Text_Hex": "请输入6位16进制颜色编号" "BI-Color_Picker_Error_Text_Hex": "请输入6位16进制颜色编号",
"BI-Basic_Date_Range_Error": "请选择{R1}年{R2}月{R3}日-{R4}年{R5}月{R6}日的日期",
"BI-Basic_Year_Range_Error": "请选择{R1}年-{R2}年的日期",
"BI-Basic_Year_Month_Range_Error": "请选择{R1}年{R2}月-{R3}年{R4}月的日期",
"BI-Basic_Year_Quarter_Range_Error": "请选择{R1}年{R2}季度-{R3}年{R4}季度的日期",
}; };

6
src/core/platform/web/dom.js

@ -659,7 +659,7 @@
} else { } else {
pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight); pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
} }
pos.dir = "right" + pos.dir; pos.dir = "right," + pos.dir;
if (tbFirst) { if (tbFirst) {
pos.change = "right"; pos.change = "right";
} }
@ -721,7 +721,7 @@
} else { } else {
pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight); pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
} }
pos.dir = "innerLeft" + pos.dir; pos.dir = "innerLeft," + pos.dir;
if (tbFirst) { if (tbFirst) {
pos.change = "innerLeft"; pos.change = "innerLeft";
} }
@ -741,7 +741,7 @@
} else { } else {
pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight); pos = BI.DOM.getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
} }
pos.dir = "innerLeft" + pos.dir; pos.dir = "innerLeft," + pos.dir;
if (tbFirst) { if (tbFirst) {
pos.change = "innerRight"; pos.change = "innerRight";
} }

30
src/widget/datepane/card.static.datepane.js

@ -141,6 +141,36 @@ BI.StaticDatePaneCard = BI.inherit(BI.Widget, {
} }
}, },
_checkMin: function () {
var o = this.options;
BI.each(this.calendar.getAllCard(), function (idx, calendar) {
calendar.setMinDate(o.min);
});
},
_checkMax: function () {
var o = this.options;
BI.each(this.calendar.getAllCard(), function (idx, calendar) {
calendar.setMaxDate(o.max);
});
},
setMinDate: function (minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
this.datePicker.setMinDate(minDate);
this._checkMin();
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
this.datePicker.setMaxDate(maxDate);
this._checkMax();
}
},
setValue: function (timeOb) { setValue: function (timeOb) {
this._setDatePicker(timeOb); this._setDatePicker(timeOb);
this._setCalendar(timeOb); this._setCalendar(timeOb);

17
src/widget/datepane/datepane.js

@ -63,6 +63,8 @@ BI.DynamicDatePane = BI.inherit(BI.Widget, {
case BI.DynamicDatePane.Static: case BI.DynamicDatePane.Static:
return { return {
type: "bi.static_date_pane_card", type: "bi.static_date_pane_card",
min: o.minDate,
max: o.maxDate,
behaviors: o.behaviors, behaviors: o.behaviors,
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
@ -119,6 +121,21 @@ BI.DynamicDatePane = BI.inherit(BI.Widget, {
} }
}, },
setMinDate: function (minDate) {
if (this.options.minDate !== minDate) {
this.options.minDate = minDate;
this.ymd.setMinDate(minDate);
}
},
setMaxDate: function (maxDate) {
if (this.options.maxDate !== maxDate) {
this.options.maxDate = maxDate;
this.ymd.setMaxDate(maxDate);
}
},
setValue: function (v) { setValue: function (v) {
v = v || {}; v = v || {};
var type = v.type || BI.DynamicDateCombo.Static; var type = v.type || BI.DynamicDateCombo.Static;

30
src/widget/datetimepane/card.static.datetimepane.js

@ -155,6 +155,36 @@ BI.StaticDateTimePaneCard = BI.inherit(BI.Widget, {
} }
}, },
_checkMin: function () {
var o = this.options;
BI.each(this.calendar.getAllCard(), function (idx, calendar) {
calendar.setMinDate(o.min);
});
},
_checkMax: function () {
var o = this.options;
BI.each(this.calendar.getAllCard(), function (idx, calendar) {
calendar.setMaxDate(o.max);
});
},
setMinDate: function (minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
this.datePicker.setMinDate(minDate);
this._checkMin();
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
this.datePicker.setMaxDate(maxDate);
this._checkMax();
}
},
setValue: function (timeOb) { setValue: function (timeOb) {
timeOb = timeOb || {}; timeOb = timeOb || {};
this._setDatePicker(timeOb); this._setDatePicker(timeOb);

16
src/widget/datetimepane/datetimepane.js

@ -62,6 +62,8 @@ BI.DynamicDateTimePane = BI.inherit(BI.Widget, {
case BI.DynamicDateTimePane.Static: case BI.DynamicDateTimePane.Static:
return { return {
type: "bi.static_date_time_pane_card", type: "bi.static_date_time_pane_card",
min: o.minDate,
max: o.maxDate,
behaviors: o.behaviors, behaviors: o.behaviors,
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
@ -118,6 +120,20 @@ BI.DynamicDateTimePane = BI.inherit(BI.Widget, {
} }
}, },
setMinDate: function (minDate) {
if (this.options.minDate !== minDate) {
this.options.minDate = minDate;
this.ymd.setMinDate(minDate);
}
},
setMaxDate: function (maxDate) {
if (this.options.maxDate !== maxDate) {
this.options.maxDate = maxDate;
this.ymd.setMaxDate(maxDate);
}
},
setValue: function (v) { setValue: function (v) {
v = v || {}; v = v || {};
var type = v.type || BI.DynamicDateTimePane.Static; var type = v.type || BI.DynamicDateTimePane.Static;

97
src/widget/dynamicdate/dynamicdate.card.js

@ -134,11 +134,24 @@ BI.DynamicDateCard = BI.inherit(BI.Widget, {
}, },
_getParamJson: function (values, positionValue) { _getParamJson: function (values, positionValue) {
var self = this; var self = this, o = this.options;
var items = BI.map(values, function (idx, value) { var items = BI.map(values, function (idx, value) {
return { return {
el: { el: {
type: "bi.dynamic_date_param_item", type: "bi.dynamic_date_param_item",
validationChecker: BI.bind(self._checkDate, self),
errorText: function () {
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
return BI.i18nText("BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),
end.getFullYear(),
end.getMonth() + 1,
end.getDate()
);
},
dateType: value.dateType, dateType: value.dateType,
value: value.value, value: value.value,
offset: value.offset, offset: value.offset,
@ -165,7 +178,7 @@ BI.DynamicDateCard = BI.inherit(BI.Widget, {
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
self.position = this.getValue()[0]; this.setValue(self._checkPositionValue(this.getValue()[0]));
self.fireEvent("EVENT_CHANGE"); self.fireEvent("EVENT_CHANGE");
} }
}] }]
@ -181,7 +194,7 @@ BI.DynamicDateCard = BI.inherit(BI.Widget, {
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
self.position = this.getValue()[0]; this.setValue(self._checkPositionValue(this.getValue()[0]));
self.fireEvent("EVENT_CHANGE"); self.fireEvent("EVENT_CHANGE");
} }
}] }]
@ -193,6 +206,22 @@ BI.DynamicDateCard = BI.inherit(BI.Widget, {
return items; return items;
}, },
_checkPositionValue: function (v) {
var lastPosition = this.position;
this.position = v;
if (!this._checkDate({})) {
this.position = lastPosition;
}
return this.position;
},
_checkDate: function (obj) {
var o = this.options;
var date = BI.DynamicDateHelper.getCalculation(BI.extend(this.getValue(), this._digestDateTypeValue(obj)));
return !BI.checkDateVoid(date.getFullYear(), date.getMonth() + 1, date.getDate(), o.min, o.max)[0];
},
_getText: function (lastValue) { _getText: function (lastValue) {
switch (lastValue) { switch (lastValue) {
case BI.DynamicDateCard.TYPE.YEAR: case BI.DynamicDateCard.TYPE.YEAR:
@ -251,6 +280,45 @@ BI.DynamicDateCard = BI.inherit(BI.Widget, {
}; };
}, },
_digestDateTypeValue: function (value) {
var valueMap = {};
switch (value.dateType) {
case BI.DynamicDateCard.TYPE.YEAR:
valueMap.year = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.QUARTER:
valueMap.quarter = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.MONTH:
valueMap.month = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.WEEK:
valueMap.week = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.DAY:
valueMap.day = (value.offset === 0 ? -value.value : value.value);
break;
default:
break;
}
if(BI.isNull(value.dateType)) {
valueMap.position = self.position || BI.DynamicDateCard.OFFSET.CURRENT;
}
return valueMap;
},
setMinDate: function(minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
},
setValue: function (v) { setValue: function (v) {
v = v || {}; v = v || {};
this.position = v.position || BI.DynamicDateCard.OFFSET.CURRENT; this.position = v.position || BI.DynamicDateCard.OFFSET.CURRENT;
@ -293,28 +361,7 @@ BI.DynamicDateCard = BI.inherit(BI.Widget, {
if(selectValues.length !== 0) { if(selectValues.length !== 0) {
BI.each(buttons, function (idx, button) { BI.each(buttons, function (idx, button) {
var value = button.getValue(); var value = button.getValue();
switch (value.dateType) { BI.extend(valueMap, self._digestDateTypeValue(value));
case BI.DynamicDateCard.TYPE.YEAR:
valueMap.year = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.QUARTER:
valueMap.quarter = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.MONTH:
valueMap.month = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.WEEK:
valueMap.week = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.DAY:
valueMap.day = (value.offset === 0 ? -value.value : value.value);
break;
default:
break;
}
if(BI.isNull(value.dateType)) {
valueMap.position = self.position || BI.DynamicDateCard.OFFSET.CURRENT;
}
}); });
} }
if(this.workDayBox.isSelected()) { if(this.workDayBox.isSelected()) {

21
src/widget/dynamicdate/dynamicdate.param.item.js

@ -3,6 +3,12 @@ BI.DynamicDateParamItem = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "bi-dynamic-date-param-item", baseCls: "bi-dynamic-date-param-item",
dateType: BI.DynamicDateCard.TYPE.YEAR, dateType: BI.DynamicDateCard.TYPE.YEAR,
validationChecker: function() {
return true;
},
errorText: function () {
return BI.i18nText("BI-Please_Input_Natural_Number");
},
value: 0, value: 0,
offset: 0, offset: 0,
height: 24 height: 24
@ -18,17 +24,23 @@ BI.DynamicDateParamItem = BI.inherit(BI.Widget, {
cls: "bi-border", cls: "bi-border",
height: 22, height: 22,
validationChecker: function (v) { validationChecker: function (v) {
return BI.isNaturalNumber(v); return BI.isNaturalNumber(v) && o.validationChecker(BI.extend({}, self.getValue(), {
value: v
}));
}, },
value: o.value, value: o.value,
ref: function () { ref: function () {
self.editor = this; self.editor = this;
}, },
errorText: function (v) { errorText: function (v) {
if(BI.isEmptyString(v)) { if (BI.isEmptyString(v)) {
return BI.i18nText("BI-Basic_Please_Input_Content"); return BI.i18nText("BI-Basic_Please_Input_Content");
} }
return BI.i18nText("BI-Please_Input_Natural_Number"); if (!BI.isNumeric(v)) {
return BI.i18nText("BI-Please_Input_Natural_Number");
}
return o.errorText(v);
}, },
allowBlank: false, allowBlank: false,
listeners: [{ listeners: [{
@ -64,6 +76,9 @@ BI.DynamicDateParamItem = BI.inherit(BI.Widget, {
listeners: [{ listeners: [{
eventName: BI.TextValueCombo.EVENT_CHANGE, eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () { action: function () {
if (!o.validationChecker(self.getValue())) {
self.editor.setValue(0);
}
self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE); self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE);
} }
}] }]

8
src/widget/dynamicdate/dynamicdate.popup.js

@ -101,6 +101,8 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
self._setInnerValue(self.year, v); self._setInnerValue(self.year, v);
} }
}], }],
min: self.options.min,
max: self.options.max,
ref: function () { ref: function () {
self.dynamicPane = this; self.dynamicPane = this;
} }
@ -179,14 +181,16 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
setMinDate: function (minDate) { setMinDate: function (minDate) {
if (this.options.min !== minDate) { if (this.options.min !== minDate) {
this.options.min = minDate; this.options.min = minDate;
this.ymd.setMinDate(minDate); this.ymd && this.ymd.setMinDate(minDate);
this.dynamicPane && this.ymd.setMinDate(minDate);
} }
}, },
setMaxDate: function (maxDate) { setMaxDate: function (maxDate) {
if (this.options.max !== maxDate) { if (this.options.max !== maxDate) {
this.options.max = maxDate; this.options.max = maxDate;
this.ymd.setMaxDate(maxDate); this.ymd && this.ymd.setMaxDate(maxDate);
this.dynamicPane && this.ymd.setMaxDate(maxDate);
} }
}, },

2
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -199,9 +199,9 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
listeners: [{ listeners: [{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: function () { action: function () {
self.popup.setValue(self.storeValue);
self.popup.setMinDate(opts.minDate); self.popup.setMinDate(opts.minDate);
self.popup.setMaxDate(opts.maxDate); self.popup.setMaxDate(opts.maxDate);
self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
} }
}], }],

4
src/widget/dynamicdatetime/dynamicdatetime.popup.js

@ -103,7 +103,9 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
}], }],
ref: function () { ref: function () {
self.dynamicPane = this; self.dynamicPane = this;
} },
min: self.options.min,
max: self.options.max,
}; };
case BI.DynamicDateCombo.Static: case BI.DynamicDateCombo.Static:
default: default:

17
src/widget/timeinterval/dateinterval.js

@ -68,6 +68,8 @@ BI.DateInterval = BI.inherit(BI.Single, {
var self = this, o = this.options; var self = this, o = this.options;
var combo = BI.createWidget({ var combo = BI.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
minDate: o.minDate,
maxDate: o.maxDate,
behaviors: o.behaviors, behaviors: o.behaviors,
value: v, value: v,
height: o.height, height: o.height,
@ -174,6 +176,21 @@ BI.DateInterval = BI.inherit(BI.Single, {
this.right.setTitle(""); this.right.setTitle("");
this.label.setTitle(""); this.label.setTitle("");
}, },
setMinDate: function (minDate) {
var o = this.options;
o.minDate = minDate;
this.left.setMinDate(minDate);
this.right.setMinDate(minDate);
},
setMaxDate: function (maxDate) {
var o = this.options;
o.maxDate = maxDate;
this.left.setMaxDate(maxDate);
this.right.setMaxDate(maxDate);
},
setValue: function (date) { setValue: function (date) {
date = date || {}; date = date || {};
this.left.setValue(date.start); this.left.setValue(date.start);

17
src/widget/timeinterval/timeinterval.js

@ -68,6 +68,8 @@ BI.TimeInterval = BI.inherit(BI.Single, {
var self = this, o = this.options; var self = this, o = this.options;
var combo = BI.createWidget({ var combo = BI.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
minDate: o.minDate,
maxDate: o.maxDate,
behaviors: o.behaviors, behaviors: o.behaviors,
value: v, value: v,
height: o.height, height: o.height,
@ -169,6 +171,21 @@ BI.TimeInterval = BI.inherit(BI.Single, {
this.right.setTitle(""); this.right.setTitle("");
this.label.setTitle(""); this.label.setTitle("");
}, },
setMinDate: function (minDate) {
var o = this.options;
o.minDate = minDate;
this.left.setMinDate(minDate);
this.right.setMinDate(minDate);
},
setMaxDate: function (maxDate) {
var o = this.options;
o.maxDate = maxDate;
this.left.setMaxDate(maxDate);
this.right.setMaxDate(maxDate);
},
setValue: function (date) { setValue: function (date) {
date = date || {}; date = date || {};
this.left.setValue(date.start); this.left.setValue(date.start);

32
src/widget/year/card.dynamic.year.js

@ -12,7 +12,7 @@ BI.DynamicYearCard = BI.inherit(BI.Widget, {
}, },
render: function () { render: function () {
var self = this; var self = this, o = this.options;
return { return {
type: "bi.vertical", type: "bi.vertical",
items: [{ items: [{
@ -25,6 +25,15 @@ BI.DynamicYearCard = BI.inherit(BI.Widget, {
ref: function () { ref: function () {
self.item = this; self.item = this;
}, },
validationChecker: BI.bind(self._checkDate, self),
errorText: function () {
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
return BI.i18nText("BI-Basic_Year_Range_Error",
start.getFullYear(),
end.getFullYear(),
);
},
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
@ -37,6 +46,15 @@ BI.DynamicYearCard = BI.inherit(BI.Widget, {
}; };
}, },
_checkDate: function (obj) {
var o = this.options;
var date = BI.DynamicDateHelper.getCalculation({
year: (obj.offset === 0 ? -obj.value : obj.value)
});
return !BI.checkDateVoid(date.getFullYear(), date.getMonth() + 1, date.getDate(), o.min, o.max)[0];
},
_createValue: function (type, v) { _createValue: function (type, v) {
return { return {
dateType: type, dateType: type,
@ -45,6 +63,18 @@ BI.DynamicYearCard = BI.inherit(BI.Widget, {
}; };
}, },
setMinDate: function(minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
},
setValue: function (v) { setValue: function (v) {
v = v || {year: 0}; v = v || {year: 0};
this.item.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); this.item.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));

32
src/widget/year/card.year.js

@ -134,6 +134,38 @@ BI.StaticYearCard = BI.inherit(BI.Widget, {
return valid; return valid;
}, },
_checkMin: function () {
var o = this.options;
BI.each(this.navigation.getAllCard(), function (idx, calendar) {
calendar.setMinDate(o.min);
});
},
_checkMax: function () {
var o = this.options;
BI.each(this.navigation.getAllCard(), function (idx, calendar) {
calendar.setMaxDate(o.max);
});
},
setMinDate: function (minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
this._checkLeftValid();
this._checkRightValid();
this._checkMin();
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
this._checkLeftValid();
this._checkRightValid();
this._checkMax();
}
},
getValue: function () { getValue: function () {
return { return {
year: this.selectedYear year: this.selectedYear

28
src/widget/year/combo.year.js

@ -3,8 +3,8 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "bi-year-combo bi-border bi-border-radius bi-focus-shadow", baseCls: "bi-year-combo bi-border bi-border-radius bi-focus-shadow",
behaviors: {}, behaviors: {},
min: "1900-01-01", // 最小日期 minDate: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期 maxDate: "2099-12-31", // 最大日期
height: 22 height: 22
}, },
@ -14,8 +14,8 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
this.storeValue = o.value; this.storeValue = o.value;
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.dynamic_year_trigger", type: "bi.dynamic_year_trigger",
min: o.min, min: o.minDate,
max: o.max, max: o.maxDate,
height: o.height, height: o.height,
value: o.value || "" value: o.value || ""
}); });
@ -96,13 +96,15 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
} }
}], }],
behaviors: o.behaviors, behaviors: o.behaviors,
min: o.min, min: o.minDate,
max: o.max max: o.maxDate
}, },
value: o.value || "" value: o.value || ""
} }
}); });
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setMinDate(o.minDate);
self.popup.setMaxDate(o.maxDate);
self.popup.setValue(self.storeValue); self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW); self.fireEvent(BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW);
}); });
@ -148,6 +150,20 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
} }
}, },
setMinDate: function (minDate) {
var o = this.options;
o.minDate = minDate;
this.trigger.setMinDate(minDate);
this.popup && this.popup.setMinDate(minDate);
},
setMaxDate: function (maxDate) {
var o = this.options;
o.maxDate = maxDate;
this.trigger.setMaxDate(maxDate);
this.popup && this.popup.setMaxDate(maxDate);
},
setValue: function (v) { setValue: function (v) {
this.storeValue = v; this.storeValue = v;
this.trigger.setValue(v); this.trigger.setValue(v);

18
src/widget/year/popup.year.js

@ -114,6 +114,8 @@ BI.DynamicYearPopup = BI.inherit(BI.Widget, {
case BI.DynamicYearCombo.Dynamic: case BI.DynamicYearCombo.Dynamic:
return { return {
type: "bi.dynamic_year_card", type: "bi.dynamic_year_card",
min: self.options.min,
max: self.options.max,
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
@ -170,6 +172,22 @@ BI.DynamicYearPopup = BI.inherit(BI.Widget, {
}; };
}, },
setMinDate: function (minDate) {
if (this.options.min !== minDate) {
this.options.min = minDate;
this.year && this.year.setMinDate(minDate);
this.dynamicPane && this.dynamicPane.setMinDate(minDate);
}
},
setMaxDate: function (maxDate) {
if (this.options.max !== maxDate) {
this.options.max = maxDate;
this.year && this.year.setMaxDate(maxDate);
this.dynamicPane && this.dynamicPane.setMaxDate(maxDate);
}
},
setValue: function (v) { setValue: function (v) {
this.storeValue = v; this.storeValue = v;
var self = this; var self = this;

12
src/widget/year/trigger.year.js

@ -157,6 +157,18 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
} }
}, },
setMinDate: function (minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
},
getValue: function () { getValue: function () {
return this.storeValue; return this.storeValue;
}, },

50
src/widget/yearmonth/card.dynamic.yearmonth.js

@ -22,6 +22,8 @@ BI.DynamicYearMonthCard = BI.inherit(BI.Widget, {
height: 24 height: 24
}, { }, {
type: "bi.dynamic_date_param_item", type: "bi.dynamic_date_param_item",
validationChecker: BI.bind(self._checkDate, self),
errorText: BI.bind(this._errorTextGetter, this),
ref: function () { ref: function () {
self.year = this; self.year = this;
}, },
@ -33,6 +35,8 @@ BI.DynamicYearMonthCard = BI.inherit(BI.Widget, {
}] }]
}, { }, {
type: "bi.dynamic_date_param_item", type: "bi.dynamic_date_param_item",
validationChecker: BI.bind(self._checkDate, self),
errorText: BI.bind(this._errorTextGetter, this),
dateType: BI.DynamicDateCard.TYPE.MONTH, dateType: BI.DynamicDateCard.TYPE.MONTH,
ref: function () { ref: function () {
self.month = this; self.month = this;
@ -49,6 +53,40 @@ BI.DynamicYearMonthCard = BI.inherit(BI.Widget, {
}; };
}, },
_errorTextGetter: function () {
var o = this.options;
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
return BI.i18nText("BI-Basic_Year_Month_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
end.getFullYear(),
end.getMonth() + 1,
);
},
_checkDate: function (obj) {
var o = this.options;
var date = BI.DynamicDateHelper.getCalculation(BI.extend(this.getValue(), this._digestDateTypeValue(obj)));
return !BI.checkDateVoid(date.getFullYear(), date.getMonth() + 1, date.getDate(), o.min, o.max)[0];
},
_digestDateTypeValue: function (value) {
var valueMap = {};
switch (value.dateType) {
case BI.DynamicDateCard.TYPE.YEAR:
valueMap.year = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.MONTH:
valueMap.month = (value.offset === 0 ? -value.value : value.value);
break;
default:
break;
}
return valueMap;
},
_createValue: function (type, v) { _createValue: function (type, v) {
return { return {
dateType: type, dateType: type,
@ -57,6 +95,18 @@ BI.DynamicYearMonthCard = BI.inherit(BI.Widget, {
}; };
}, },
setMinDate: function(minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
},
setValue: function (v) { setValue: function (v) {
v = v || {year: 0, month: 0}; v = v || {year: 0, month: 0};
this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));

1
src/widget/yearmonth/card.static.yearmonth.js

@ -153,6 +153,7 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
this.yearPicker.setValue(this.selectedYear); this.yearPicker.setValue(this.selectedYear);
this.month.setValue(this.selectedMonth); this.month.setValue(this.selectedMonth);
} }
this._checkMonthStatus(this.selectedYear);
} }
}); });
BI.StaticYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE"; BI.StaticYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE";

16
src/widget/yearmonth/combo.yearmonth.js

@ -107,6 +107,8 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
} }
}); });
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setMinDate(o.minDate);
self.popup.setMaxDate(o.maxDate);
self.popup.setValue(self.storeValue); self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW); self.fireEvent(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW);
}); });
@ -152,6 +154,20 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
} }
}, },
setMinDate: function (minDate) {
var o = this.options;
o.minDate = minDate;
this.trigger.setMinDate(minDate);
this.popup && this.popup.setMinDate(minDate);
},
setMaxDate: function (maxDate) {
var o = this.options;
o.maxDate = maxDate;
this.trigger.setMaxDate(maxDate);
this.popup && this.popup.setMaxDate(maxDate);
},
hideView: function () { hideView: function () {
this.combo.hideView(); this.combo.hideView();
}, },

8
src/widget/yearmonth/popup.yearmonth.js

@ -114,6 +114,8 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, {
case BI.DynamicYearCombo.Dynamic: case BI.DynamicYearCombo.Dynamic:
return { return {
type: "bi.dynamic_year_month_card", type: "bi.dynamic_year_month_card",
min: self.options.min,
max: self.options.max,
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
@ -173,14 +175,16 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, {
setMinDate: function (minDate) { setMinDate: function (minDate) {
if (this.options.min !== minDate) { if (this.options.min !== minDate) {
this.options.min = minDate; this.options.min = minDate;
this.year.setMinDate(minDate); this.year && this.year.setMinDate(minDate);
this.dynamicPane && this.dynamicPane.setMinDate(minDate);
} }
}, },
setMaxDate: function (maxDate) { setMaxDate: function (maxDate) {
if (this.options.max !== maxDate) { if (this.options.max !== maxDate) {
this.options.max = maxDate; this.options.max = maxDate;
this.year.setMaxDate(maxDate); this.year && this.year.setMaxDate(maxDate);
this.dynamicPane && this.dynamicPane.setMaxDate(maxDate);
} }
}, },

14
src/widget/yearmonth/trigger.yearmonth.js

@ -71,7 +71,7 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, parseInt(v, 10) === minDate.getFullYear() ? minDate.getMonth() + 1 : 1, 1, o.min, o.max)[0]); return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, parseInt(v, 10) === minDate.getFullYear() ? minDate.getMonth() + 1 : 1, 1, o.min, o.max)[0]);
} }
return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 12) && !BI.checkDateVoid(BI.getDate().getFullYear(), v, 1, o.min, o.max)[0]); return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 12) && !BI.checkDateVoid(self.yearEditor.getValue(), v, 1, o.min, o.max)[0]);
}, },
quitChecker: function () { quitChecker: function () {
return false; return false;
@ -215,6 +215,18 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
} }
}, },
setMinDate: function (minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
},
setValue: function (v) { setValue: function (v) {
var type, value; var type, value;
var date = BI.getDate(); var date = BI.getDate();

17
src/widget/yearmonthinterval/yearmonthinterval.js

@ -64,6 +64,8 @@ BI.YearMonthInterval = BI.inherit(BI.Single, {
var self = this, o = this.options; var self = this, o = this.options;
var combo = BI.createWidget({ var combo = BI.createWidget({
type: "bi.dynamic_year_month_combo", type: "bi.dynamic_year_month_combo",
minDate: o.minDate,
maxDate: o.maxDate,
behaviors: o.behaviors, behaviors: o.behaviors,
value: v, value: v,
listeners: [{ listeners: [{
@ -174,6 +176,21 @@ BI.YearMonthInterval = BI.inherit(BI.Single, {
self.element.removeClass(self.constants.timeErrorCls); self.element.removeClass(self.constants.timeErrorCls);
} }
}, },
setMinDate: function (minDate) {
var o = this.options;
o.minDate = minDate;
this.left.setMinDate(minDate);
this.right.setMinDate(minDate);
},
setMaxDate: function (maxDate) {
var o = this.options;
o.maxDate = maxDate;
this.left.setMaxDate(maxDate);
this.right.setMaxDate(maxDate);
},
setValue: function (date) { setValue: function (date) {
date = date || {}; date = date || {};
this.left.setValue(date.start); this.left.setValue(date.start);

50
src/widget/yearquarter/card.dynamic.yearquarter.js

@ -22,6 +22,8 @@ BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, {
height: 24 height: 24
}, { }, {
type: "bi.dynamic_date_param_item", type: "bi.dynamic_date_param_item",
validationChecker: BI.bind(self._checkDate, self),
errorText: BI.bind(this._errorTextGetter, this),
ref: function () { ref: function () {
self.year = this; self.year = this;
}, },
@ -33,6 +35,8 @@ BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, {
}] }]
}, { }, {
type: "bi.dynamic_date_param_item", type: "bi.dynamic_date_param_item",
validationChecker: BI.bind(self._checkDate, self),
errorText: BI.bind(this._errorTextGetter, this),
dateType: BI.DynamicDateCard.TYPE.QUARTER, dateType: BI.DynamicDateCard.TYPE.QUARTER,
ref: function () { ref: function () {
self.quarter = this; self.quarter = this;
@ -49,6 +53,40 @@ BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, {
}; };
}, },
_errorTextGetter: function () {
var o = this.options;
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
return BI.i18nText("BI-Basic_Year_Quarter_Range_Error",
start.getFullYear(),
BI.getQuarter(start),
end.getFullYear(),
BI.getQuarter(end),
);
},
_checkDate: function (obj) {
var o = this.options;
var date = BI.DynamicDateHelper.getCalculation(BI.extend(this.getValue(), this._digestDateTypeValue(obj)));
return !BI.checkDateVoid(date.getFullYear(), date.getMonth() + 1, date.getDate(), o.min, o.max)[0];
},
_digestDateTypeValue: function (value) {
var valueMap = {};
switch (value.dateType) {
case BI.DynamicDateCard.TYPE.YEAR:
valueMap.year = (value.offset === 0 ? -value.value : value.value);
break;
case BI.DynamicDateCard.TYPE.MONTH:
valueMap.quarter = (value.offset === 0 ? -value.value : value.value);
break;
default:
break;
}
return valueMap;
},
_createValue: function (type, v) { _createValue: function (type, v) {
return { return {
dateType: type, dateType: type,
@ -57,6 +95,18 @@ BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, {
}; };
}, },
setMinDate: function(minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
},
setValue: function (v) { setValue: function (v) {
v = v || {year: 0, month: 0}; v = v || {year: 0, month: 0};
this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));

42
src/widget/yearquarter/card.static.yearquarter.js

@ -6,7 +6,7 @@ BI.StaticYearQuarterCard = BI.inherit(BI.Widget, {
}, },
_createQuarter: function () { _createQuarter: function () {
var self = this;
var items = [{ var items = [{
text: BI.Date._QN[1], text: BI.Date._QN[1],
value: 1 value: 1
@ -28,13 +28,17 @@ BI.StaticYearQuarterCard = BI.inherit(BI.Widget, {
whiteSpace: "nowrap", whiteSpace: "nowrap",
once: false, once: false,
forceSelected: true, forceSelected: true,
height: 24 height: 24,
ref: function (_ref) {
self.quarterMap[j + 1] = _ref;
}
}); });
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.quarterMap = {};
return { return {
type: "bi.vertical", type: "bi.vertical",
items: [{ items: [{
@ -42,12 +46,15 @@ BI.StaticYearQuarterCard = BI.inherit(BI.Widget, {
ref: function () { ref: function () {
self.yearPicker = this; self.yearPicker = this;
}, },
min: o.min,
max: o.max,
behaviors: o.behaviors, behaviors: o.behaviors,
height: 30, height: 30,
listeners: [{ listeners: [{
eventName: BI.YearPicker.EVENT_CHANGE, eventName: BI.YearPicker.EVENT_CHANGE,
action: function () { action: function () {
var value = this.getValue(); var value = this.getValue();
self._checkQuarterStatus(value);
self.setValue({ self.setValue({
year: value, year: value,
quarter: self.selectedQuarter quarter: self.selectedQuarter
@ -78,6 +85,36 @@ BI.StaticYearQuarterCard = BI.inherit(BI.Widget, {
}; };
}, },
_checkQuarterStatus: function (year) {
var o = this.options;
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"), maxDate = BI.parseDateTime(o.max, "%Y-%X-%d");
var minYear = minDate.getFullYear(), maxYear = maxDate.getFullYear();
var minQuarter = 1; var maxQuarter = 4;
minYear === year && (minQuarter = BI.parseInt(BI.getQuarter(minDate)));
maxYear === year && (maxQuarter = BI.parseInt(BI.getQuarter(maxDate)));
var yearInvalid = year < minYear || year > maxYear;
BI.each(this.quarterMap, function (quarter, obj) {
var quarterInvalid = quarter < minQuarter || quarter > maxQuarter;
obj.setEnable(!yearInvalid && !quarterInvalid);
});
},
setMinDate: function (minDate) {
if (this.options.min !== minDate) {
this.options.min = minDate;
this.yearPicker.setMinDate(minDate);
this._checkQuarterStatus(this.selectedYear);
}
},
setMaxDate: function (maxDate) {
if (this.options.max !== maxDate) {
this.options.max = maxDate;
this.yearPicker.setMaxDate(maxDate);
this._checkQuarterStatus(this.selectedYear);
}
},
getValue: function () { getValue: function () {
return { return {
@ -103,6 +140,7 @@ BI.StaticYearQuarterCard = BI.inherit(BI.Widget, {
this.yearPicker.setValue(this.selectedYear); this.yearPicker.setValue(this.selectedYear);
this.quarter.setValue(this.selectedQuarter); this.quarter.setValue(this.selectedQuarter);
} }
this._checkQuarterStatus(this.selectedYear);
} }
}); });
BI.StaticYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; BI.StaticYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE";

28
src/widget/yearquarter/combo.yearquarter.js

@ -3,8 +3,8 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "bi-year-quarter-combo bi-border bi-border-radius bi-focus-shadow", baseCls: "bi-year-quarter-combo bi-border bi-border-radius bi-focus-shadow",
behaviors: {}, behaviors: {},
min: "1900-01-01", // 最小日期 minDate: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期 maxDate: "2099-12-31", // 最大日期
height: 22 height: 22
}, },
@ -15,8 +15,8 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
self.storeTriggerValue = ""; self.storeTriggerValue = "";
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.dynamic_year_quarter_trigger", type: "bi.dynamic_year_quarter_trigger",
min: o.min, min: o.minDate,
max: o.max, max: o.maxDate,
height: o.height, height: o.height,
value: o.value || "" value: o.value || ""
}); });
@ -95,13 +95,15 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
} }
}], }],
behaviors: o.behaviors, behaviors: o.behaviors,
min: o.min, min: o.minDate,
max: o.max max: o.maxDate
}, },
value: o.value || "" value: o.value || ""
} }
}); });
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setMinDate(o.minDate);
self.popup.setMaxDate(o.maxDate);
self.popup.setValue(self.storeValue); self.popup.setValue(self.storeValue);
self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW); self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
}); });
@ -147,6 +149,20 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
} }
}, },
setMinDate: function (minDate) {
var o = this.options;
o.minDate = minDate;
this.trigger.setMinDate(minDate);
this.popup && this.popup.setMinDate(minDate);
},
setMaxDate: function (maxDate) {
var o = this.options;
o.maxDate = maxDate;
this.trigger.setMaxDate(maxDate);
this.popup && this.popup.setMaxDate(maxDate);
},
setValue: function (v) { setValue: function (v) {
this.storeValue = v; this.storeValue = v;
this.trigger.setValue(v); this.trigger.setValue(v);

18
src/widget/yearquarter/popup.yearquarter.js

@ -107,6 +107,8 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, {
case BI.DynamicYearQuarterCombo.Dynamic: case BI.DynamicYearQuarterCombo.Dynamic:
return { return {
type: "bi.dynamic_year_quarter_card", type: "bi.dynamic_year_quarter_card",
min: self.options.min,
max: self.options.max,
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
@ -163,6 +165,22 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, {
}; };
}, },
setMinDate: function (minDate) {
if (this.options.min !== minDate) {
this.options.min = minDate;
this.year && this.year.setMinDate(minDate);
this.dynamicPane && this.dynamicPane.setMinDate(minDate);
}
},
setMaxDate: function (maxDate) {
if (this.options.max !== maxDate) {
this.options.max = maxDate;
this.year && this.year.setMaxDate(maxDate);
this.dynamicPane && this.dynamicPane.setMaxDate(maxDate);
}
},
setValue: function (v) { setValue: function (v) {
this.storeValue = v; this.storeValue = v;
var self = this; var self = this;

14
src/widget/yearquarter/trigger.yearquarter.js

@ -67,7 +67,7 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
if(isYear) { if(isYear) {
return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]); return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]);
} }
return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 4) && !BI.checkDateVoid(BI.getDate().getFullYear(), v, 1, o.min, o.max)[0]); return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 4) && !BI.checkDateVoid(self.yearEditor.getValue(), (v - 1) * 3 + 1, 1, o.min, o.max)[0]);
}, },
quitChecker: function () { quitChecker: function () {
return false; return false;
@ -185,6 +185,18 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr));
}, },
setMinDate: function (minDate) {
if (BI.isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
},
setMaxDate: function (maxDate) {
if (BI.isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
},
setValue: function (v) { setValue: function (v) {
var type, value; var type, value;
var date = BI.getDate(); var date = BI.getDate();

Loading…
Cancel
Save