|
|
|
BI.DynamicDateParamItem = BI.inherit(BI.Widget, {
|
|
|
|
|
|
|
|
props: {
|
|
|
|
baseCls: "bi-dynamic-date-param-item",
|
|
|
|
dateType: BI.DynamicDateCard.TYPE.YEAR,
|
|
|
|
value: 0,
|
|
|
|
offset: 0,
|
|
|
|
height: 24
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function () {
|
|
|
|
var self = this, o = this.options;
|
|
|
|
return {
|
|
|
|
type: "bi.htape",
|
|
|
|
items: [{
|
|
|
|
el: {
|
|
|
|
type: "bi.sign_editor",
|
|
|
|
cls: "bi-border",
|
|
|
|
height: 22,
|
|
|
|
validationChecker: function (v) {
|
|
|
|
return BI.isNaturalNumber(v);
|
|
|
|
},
|
|
|
|
value: o.value,
|
|
|
|
ref: function () {
|
|
|
|
self.editor = this;
|
|
|
|
},
|
|
|
|
errorText: function (v) {
|
|
|
|
if(BI.isEmptyString(v)) {
|
|
|
|
return BI.i18nText("BI-Basic_Please_Input_Content");
|
|
|
|
}
|
|
|
|
return BI.i18nText("BI-Please_Input_Positive_Integer");
|
|
|
|
},
|
|
|
|
allowBlank: false,
|
|
|
|
listeners: [{
|
|
|
|
eventName: BI.SignEditor.EVENT_CONFIRM,
|
|
|
|
action: function () {
|
|
|
|
self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE);
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
width: 60
|
|
|
|
}, {
|
|
|
|
el: {
|
|
|
|
type: "bi.label",
|
|
|
|
height: 24,
|
|
|
|
text: this._getText()
|
|
|
|
},
|
|
|
|
width: o.dateType === BI.DynamicDateCard.TYPE.WORK_DAY ? 60 : 20
|
|
|
|
}, {
|
|
|
|
type: "bi.text_value_combo",
|
|
|
|
height: 24,
|
|
|
|
items: [{
|
|
|
|
text: BI.i18nText("BI-Basic_Front"),
|
|
|
|
value: 0
|
|
|
|
}, {
|
|
|
|
text: BI.i18nText("BI-Basic_Behind"),
|
|
|
|
value: 1
|
|
|
|
}],
|
|
|
|
ref: function () {
|
|
|
|
self.offsetCombo = this;
|
|
|
|
},
|
|
|
|
value: o.offset,
|
|
|
|
listeners: [{
|
|
|
|
eventName: BI.TextValueCombo.EVENT_CHANGE,
|
|
|
|
action: function () {
|
|
|
|
self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE);
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
_getText: function () {
|
|
|
|
var text = "";
|
|
|
|
switch (this.options.dateType) {
|
|
|
|
case BI.DynamicDateCard.TYPE.YEAR:
|
|
|
|
text = BI.i18nText("BI-Basic_Year");
|
|
|
|
break;
|
|
|
|
case BI.DynamicDateCard.TYPE.QUARTER:
|
|
|
|
text = BI.i18nText("BI-Basic_Single_Quarter");
|
|
|
|
break;
|
|
|
|
case BI.DynamicDateCard.TYPE.MONTH:
|
|
|
|
text = BI.i18nText("BI-Basic_Month");
|
|
|
|
break;
|
|
|
|
case BI.DynamicDateCard.TYPE.WEEK:
|
|
|
|
text = BI.i18nText("BI-Basic_Week");
|
|
|
|
break;
|
|
|
|
case BI.DynamicDateCard.TYPE.DAY:
|
|
|
|
text = BI.i18nText("BI-Basic_Day");
|
|
|
|
break;
|
|
|
|
case BI.DynamicDateCard.TYPE.WORK_DAY:
|
|
|
|
default:
|
|
|
|
text = BI.i18nText("BI-Basic_Work_Day");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
},
|
|
|
|
|
|
|
|
setValue: function (v) {
|
|
|
|
v = v || {};
|
|
|
|
v.value = v.value || 0;
|
|
|
|
v.offset = v.offset || 0;
|
|
|
|
this.editor.setValue(v.value);
|
|
|
|
this.offsetCombo.setValue(v.offset);
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function () {
|
|
|
|
return {
|
|
|
|
dateType: this.options.dateType,
|
|
|
|
value: this.editor.getValue(),
|
|
|
|
offset: this.offsetCombo.getValue()[0]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
BI.DynamicDateParamItem.EVENT_CHANGE = "EVENT_CHANGE";
|
|
|
|
BI.shortcut("bi.dynamic_date_param_item", BI.DynamicDateParamItem);
|