Browse Source

KERNEL-12735 feat:日期相关控件水印支持

es6
zsmj 2 years ago
parent
commit
2e305edce3
  1. 4
      src/widget/dynamicdate/dynamicdate.trigger.js
  2. 9
      src/widget/time/time.trigger.js
  3. 8
      src/widget/timeinterval/dateinterval.js
  4. 10
      src/widget/timeinterval/timeinterval.js
  5. 9
      src/widget/yearinterval/yearinterval.js
  6. 3
      src/widget/yearmonth/combo.yearmonth.js
  7. 10
      src/widget/yearmonth/trigger.yearmonth.js
  8. 7
      src/widget/yearmonthinterval/yearmonthinterval.js
  9. 3
      src/widget/yearquarter/combo.yearquarter.js
  10. 10
      src/widget/yearquarter/trigger.yearquarter.js
  11. 9
      src/widget/yearquarterinterval/yearquarterinterval.js

4
src/widget/dynamicdate/dynamicdate.trigger.js

@ -17,7 +17,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
iconWidth: 24,
format: "", // 显示的日期格式化方式
allowEdit: true, // 是否允许编辑
watermark: ""
watermark: BI.i18nText("BI-Basic_Unrestricted"),
},
_init: function () {
@ -44,7 +44,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"),
watermark: o.watermark,
errorText: function (v) {
var str = "";
if (!BI.isKey(o.format)) {

9
src/widget/time/time.trigger.js

@ -27,7 +27,8 @@
extraCls: "bi-time-trigger",
value: {},
format: "",
allowEdit: false
allowEdit: false,
watermark: BI.i18nText("BI-Basic_Unrestricted"),
},
render: function () {
@ -52,7 +53,7 @@
value: this._formatValue(o.value),
hgap: 4,
allowBlank: true,
watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"),
watermark: o.watermark,
title: BI.bind(this._getTitle, this),
listeners: [{
eventName: "EVENT_KEY_DOWN",
@ -185,7 +186,7 @@
focus: function () {
this.editor.focus();
},
blur: function () {
this.editor.blur();
},
@ -195,4 +196,4 @@
}
});
BI.shortcut("bi.time_trigger", BI.TimeTrigger);
})();
})();

8
src/widget/timeinterval/dateinterval.js

@ -24,8 +24,8 @@ BI.DateInterval = BI.inherit(BI.Single, {
BI.DateInterval.superclass._init.apply(this, arguments);
o.value = o.value || {};
this.left = this._createCombo(o.value.start);
this.right = this._createCombo(o.value.end);
this.left = this._createCombo(o.value.start, o.watermark?.start);
this.right = this._createCombo(o.value.end, o.watermark?.end);
this.label = BI.createWidget({
type: "bi.label",
height: o.height,
@ -65,7 +65,7 @@ BI.DateInterval = BI.inherit(BI.Single, {
});
},
_createCombo: function (v) {
_createCombo: function (v, watermark) {
var self = this, o = this.options;
var combo = BI.createWidget({
type: "bi.dynamic_date_combo",
@ -74,7 +74,7 @@ BI.DateInterval = BI.inherit(BI.Single, {
maxDate: o.maxDate,
simple: o.simple,
behaviors: o.behaviors,
watermark: o.watermark,
watermark: watermark,
value: v,
height: o.height,
listeners: [{

10
src/widget/timeinterval/timeinterval.js

@ -24,8 +24,8 @@ BI.TimeInterval = BI.inherit(BI.Single, {
BI.TimeInterval.superclass._init.apply(this, arguments);
o.value = o.value || {};
this.left = this._createCombo(o.value.start);
this.right = this._createCombo(o.value.end);
this.left = this._createCombo(o.value.start, o.watermark?.start);
this.right = this._createCombo(o.value.end, o.watermark?.end);
this.label = BI.createWidget({
type: "bi.label",
height: o.height,
@ -65,7 +65,7 @@ BI.TimeInterval = BI.inherit(BI.Single, {
});
},
_createCombo: function (v) {
_createCombo: function (v, watermark) {
var self = this, o = this.options;
var combo = BI.createWidget({
type: "bi.dynamic_date_time_combo",
@ -74,7 +74,7 @@ BI.TimeInterval = BI.inherit(BI.Single, {
minDate: o.minDate,
maxDate: o.maxDate,
behaviors: o.behaviors,
watermark: o.watermark,
watermark: watermark,
value: v,
height: o.height,
});
@ -202,4 +202,4 @@ BI.TimeInterval = BI.inherit(BI.Single, {
BI.TimeInterval.EVENT_VALID = "EVENT_VALID";
BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR";
BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.time_interval", BI.TimeInterval);
BI.shortcut("bi.time_interval", BI.TimeInterval);

9
src/widget/yearinterval/yearinterval.js

@ -23,8 +23,8 @@ BI.YearInterval = BI.inherit(BI.Single, {
var self = this, o = this.options;
o.value = o.value || {};
this.left = this._createCombo(o.value.start);
this.right = this._createCombo(o.value.end);
this.left = this._createCombo(o.value.start, o.watermark?.start);
this.right = this._createCombo(o.value.end, o.watermark?.end);
return [{
type: "bi.center",
@ -63,7 +63,7 @@ BI.YearInterval = BI.inherit(BI.Single, {
}]
},
_createCombo: function (v) {
_createCombo: function (v, watermark) {
var self = this, o = this.options;
var combo = BI.createWidget({
type: "bi.dynamic_year_combo",
@ -73,6 +73,7 @@ BI.YearInterval = BI.inherit(BI.Single, {
height: o.height,
behaviors: o.behaviors,
value: v,
watermark: watermark,
listeners: [{
eventName: BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
@ -206,4 +207,4 @@ BI.YearInterval.EVENT_VALID = "EVENT_VALID";
BI.YearInterval.EVENT_ERROR = "EVENT_ERROR";
BI.YearInterval.EVENT_CHANGE = "EVENT_CHANGE";
BI.YearInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.year_interval", BI.YearInterval);
BI.shortcut("bi.year_interval", BI.YearInterval);

3
src/widget/yearmonth/combo.yearmonth.js

@ -23,7 +23,8 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
min: o.minDate,
max: o.maxDate,
height: o.height - border,
value: o.value || ""
value: o.value || "",
watermark: o.watermark,
});
this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN, function () {
self.combo.isViewVisible() && self.combo.hideView();

10
src/widget/yearmonth/trigger.yearmonth.js

@ -9,7 +9,11 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
extraCls: "bi-year-month-trigger",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
height: 24,
watermark: {
year: BI.i18nText("BI-Basic_Unrestricted"),
month: BI.i18nText("BI-Basic_Unrestricted"),
},
},
beforeInit: function (callback) {
@ -80,7 +84,7 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
quitChecker: function () {
return false;
},
watermark: BI.i18nText("BI-Basic_Unrestricted"),
watermark: isYear ? o.watermark?.year : o.watermark.month,
errorText: function (v) {
var year = isYear ? v : self.yearEditor.getValue();
var month = isYear ? self.monthEditor.getValue() : v;
@ -288,4 +292,4 @@ BI.DynamicYearMonthTrigger.EVENT_START = "EVENT_START";
BI.DynamicYearMonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearMonthTrigger.EVENT_STOP = "EVENT_STOP";
BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);
BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);

7
src/widget/yearmonthinterval/yearmonthinterval.js

@ -19,8 +19,8 @@ BI.YearMonthInterval = BI.inherit(BI.Single, {
BI.YearMonthInterval.superclass._init.apply(this, arguments);
o.value = o.value || {};
this.left = this._createCombo(o.value.start);
this.right = this._createCombo(o.value.end);
this.left = this._createCombo(o.value.start, o.watermark?.start);
this.right = this._createCombo(o.value.end, o.watermark?.end);
this.label = BI.createWidget({
type: "bi.label",
height: o.height,
@ -61,7 +61,7 @@ BI.YearMonthInterval = BI.inherit(BI.Single, {
});
},
_createCombo: function (v) {
_createCombo: function (v, watermark) {
var self = this, o = this.options;
var combo = BI.createWidget({
type: "bi.dynamic_year_month_combo",
@ -71,6 +71,7 @@ BI.YearMonthInterval = BI.inherit(BI.Single, {
maxDate: o.maxDate,
behaviors: o.behaviors,
value: v,
watermark: watermark,
listeners: [{
eventName: BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {

3
src/widget/yearquarter/combo.yearquarter.js

@ -26,7 +26,8 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
min: o.minDate,
max: o.maxDate,
height: o.height - border,
value: o.value || ""
value: o.value || "",
watermark: o.watermark,
});
this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN, function () {
self.combo.isViewVisible() && self.combo.hideView();

10
src/widget/yearquarter/trigger.yearquarter.js

@ -9,7 +9,11 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
extraCls: "bi-year-quarter-trigger",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24
height: 24,
watermark: {
year: BI.i18nText("BI-Basic_Unrestricted"),
quarter: BI.i18nText("BI-Basic_Unrestricted"),
},
},
_init: function () {
@ -96,7 +100,7 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
BI.getQuarter(end)
);
},
watermark: BI.i18nText("BI-Basic_Unrestricted"),
watermark: isYear ? o.watermark?.year : o.watermark?.quarter,
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true
@ -272,4 +276,4 @@ BI.DynamicYearQuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DynamicYearQuarterTrigger.EVENT_STOP = "EVENT_STOP";
BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.DynamicYearQuarterTrigger.EVENT_VALID = "EVENT_VALID";
BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger);
BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger);

9
src/widget/yearquarterinterval/yearquarterinterval.js

@ -23,8 +23,8 @@ BI.YearQuarterInterval = BI.inherit(BI.Single, {
var self = this, o = this.options;
o.value = o.value || {};
this.left = this._createCombo(o.value.start);
this.right = this._createCombo(o.value.end);
this.left = this._createCombo(o.value.start, o.watermark?.start);
this.right = this._createCombo(o.value.end, o.watermark?.end);
return [{
type: "bi.center",
@ -63,7 +63,7 @@ BI.YearQuarterInterval = BI.inherit(BI.Single, {
}]
},
_createCombo: function (v) {
_createCombo: function (v, watermark) {
var self = this, o = this.options;
var combo = BI.createWidget({
type: "bi.dynamic_year_quarter_combo",
@ -73,6 +73,7 @@ BI.YearQuarterInterval = BI.inherit(BI.Single, {
behaviors: o.behaviors,
value: v,
height: o.height,
watermark: watermark,
listeners: [{
eventName: BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW,
action: function () {
@ -204,4 +205,4 @@ BI.YearQuarterInterval.EVENT_VALID = "EVENT_VALID";
BI.YearQuarterInterval.EVENT_ERROR = "EVENT_ERROR";
BI.YearQuarterInterval.EVENT_CHANGE = "EVENT_CHANGE";
BI.YearQuarterInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.year_quarter_interval", BI.YearQuarterInterval);
BI.shortcut("bi.year_quarter_interval", BI.YearQuarterInterval);

Loading…
Cancel
Save