Browse Source

KERNEL-552 feat: 日期类型控件允许配置是否可以输入

es6
windy 5 years ago
parent
commit
7fa489476e
  1. 2
      demo/js/widget/date/demo.multidate_combo.js
  2. 4
      src/widget/dynamicdate/dynamicdate.combo.js
  3. 57
      src/widget/dynamicdate/dynamicdate.trigger.js
  4. 4
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  5. 58
      src/widget/dynamicdatetime/dynamicdatetime.trigger.js
  6. 3
      src/widget/time/time.trigger.js

2
demo/js/widget/date/demo.multidate_combo.js

@ -21,6 +21,7 @@ Demo.Date = BI.inherit(BI.Widget, {
self.datecombo = this;
},
width: 300,
// allowEdit: false,
// format: "%Y-%X-%d", // yyyy-MM-dd
// format: "%Y/%X/%d", // yyyy/MM/dd
// format: "%Y-%x-%e", // yyyy-M-d
@ -51,6 +52,7 @@ Demo.Date = BI.inherit(BI.Widget, {
self.datetimecombo = this;
},
width: 300,
// allowEdit: false,
// format: "%Y-%X-%d %H:%M:%S", // yyyy-MM-dd HH:mm:ss
// format: "%Y/%X/%d %H:%M:%S", // yyyy/MM/dd HH:mm:ss
// format: "%Y-%X-%d %I:%M:%S", // yyyy-MM-dd hh:mm:ss

4
src/widget/dynamicdate/dynamicdate.combo.js

@ -11,7 +11,8 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
height: 22,
minDate: "1900-01-01",
maxDate: "2099-12-31",
format: ""
format: "",
allowEdit: true
},
@ -50,6 +51,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
min: opts.minDate,
max: opts.maxDate,
format: opts.format,
allowEdit: opts.allowEdit,
height: opts.height,
value: opts.value,
ref: function () {

57
src/widget/dynamicdate/dynamicdate.trigger.js

@ -13,7 +13,8 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24,
format: "" // 显示的日期格式化方式
format: "", // 显示的日期格式化方式
allowEdit: true // 是否允许编辑
},
_init: function () {
@ -47,25 +48,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
}
return str;
},
title: function () {
var storeValue = self.storeValue || {};
var type = storeValue.type || BI.DynamicDateCombo.Static;
var value = storeValue.value;
switch (type) {
case BI.DynamicDateCombo.Dynamic:
var text = self._getText(value);
var date = BI.getDate();
date = BI.DynamicDateHelper.getCalculation(value);
var dateStr = BI.print(date, self._getFormatString());
return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
case BI.DynamicDateCombo.Static:
default:
if (BI.isNull(value) || BI.isNull(value.day)) {
return "";
}
return BI.print(BI.getDate(value.year, (value.month - 1), value.day), self._getFormatString());
}
}
title: BI.bind(this._getTitle, this)
});
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
self.fireEvent(BI.DynamicDateTrigger.EVENT_KEY_DOWN);
@ -124,9 +107,43 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
width: 24
}]
});
!o.allowEdit && BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.text",
title: BI.bind(this._getTitle, this)
},
left: 0,
right: 24,
top: 0,
bottom: 0
}]
});
this.setValue(o.value);
},
_getTitle: function () {
var storeValue = this.storeValue || {};
var type = storeValue.type || BI.DynamicDateCombo.Static;
var value = storeValue.value;
switch (type) {
case BI.DynamicDateCombo.Dynamic:
var text = this._getText(value);
var date = BI.getDate();
date = BI.DynamicDateHelper.getCalculation(value);
var dateStr = BI.print(date, this._getFormatString());
return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
case BI.DynamicDateCombo.Static:
default:
if (BI.isNull(value) || BI.isNull(value.day)) {
return "";
}
return BI.print(BI.getDate(value.year, (value.month - 1), value.day), this._getFormatString());
}
},
_getStandardDateStr: function (v) {
var c = this._const;
var result = [0, 1, 2];

4
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -11,7 +11,8 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
height: 22,
minDate: "1900-01-01",
maxDate: "2099-12-31",
format: ""
format: "",
allowEdit: true
},
@ -49,6 +50,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
type: "bi.dynamic_date_time_trigger",
min: opts.minDate,
max: opts.maxDate,
allowEdit: opts.allowEdit,
format: opts.format,
height: opts.height,
value: opts.value,

58
src/widget/dynamicdatetime/dynamicdatetime.trigger.js

@ -13,7 +13,8 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24,
format: "" // 显示的日期格式化方式
format: "", // 显示的日期格式化方式
allowEdit: true // 是否允许编辑
},
_init: function () {
@ -47,25 +48,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
}
return str;
},
title: function () {
var storeValue = self.storeValue || {};
var type = storeValue.type || BI.DynamicDateCombo.Static;
var value = storeValue.value;
switch (type) {
case BI.DynamicDateCombo.Dynamic:
var text = self._getText(value);
var date = BI.DynamicDateHelper.getCalculation(value);
var dateStr = BI.print(date, self._getFormatString());
return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
case BI.DynamicDateCombo.Static:
default:
if (BI.isNull(value) || BI.isNull(value.day)) {
return "";
}
return BI.print(BI.getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0,
value.second || 0), self._getFormatString());
}
}
title: BI.bind(this._getTitle, this)
});
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN);
@ -122,9 +105,44 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
width: 24
}]
});
!o.allowEdit && BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.text",
title: BI.bind(this._getTitle, this)
},
left: 0,
right: 24,
top: 0,
bottom: 0
}]
});
this.setValue(o.value);
},
_getTitle: function () {
var storeValue = this.storeValue || {};
var type = storeValue.type || BI.DynamicDateCombo.Static;
var value = storeValue.value;
switch (type) {
case BI.DynamicDateCombo.Dynamic:
var text = this._getText(value);
var date = BI.DynamicDateHelper.getCalculation(value);
var dateStr = BI.print(date, this._getFormatString());
return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
case BI.DynamicDateCombo.Static:
default:
if (BI.isNull(value) || BI.isNull(value.day)) {
return "";
}
return BI.print(BI.getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0,
value.second || 0), this._getFormatString());
}
},
_getStandardDateStr: function (v) {
var result = [];
var hasSecond = false;

3
src/widget/time/time.trigger.js

@ -135,7 +135,8 @@
_getTitle: function () {
var storeValue = this.storeValue || {};
return BI.print(BI.getDate(storeValue.year, (storeValue.month - 1), storeValue.day), this._getFormatString());
var date = BI.getDate();
return BI.print(BI.getDate(date.getFullYear(), 0, 1, storeValue.hour, storeValue.minute, storeValue.second), this._getFormatString());
},
_getFormatString: function () {

Loading…
Cancel
Save