|
|
|
@ -30,229 +30,240 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
|
|
|
|
|
this.storeTriggerValue = ""; |
|
|
|
|
var date = BI.getDate(); |
|
|
|
|
this.storeValue = opts.value; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
type: "bi.htape", |
|
|
|
|
cls: "bi-border bi-border-radius", |
|
|
|
|
type: "bi.absolute", |
|
|
|
|
items: [{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.icon_button", |
|
|
|
|
cls: "bi-trigger-icon-button date-change-h-font", |
|
|
|
|
width: opts.height, |
|
|
|
|
height: opts.height - 2, |
|
|
|
|
ref: function () { |
|
|
|
|
self.changeIcon = this; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
width: opts.height |
|
|
|
|
}, { |
|
|
|
|
type: "bi.absolute", |
|
|
|
|
items: [{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.combo", |
|
|
|
|
destroyWhenHide: true, |
|
|
|
|
container: opts.container, |
|
|
|
|
ref: function () { |
|
|
|
|
self.combo = this; |
|
|
|
|
}, |
|
|
|
|
toggle: false, |
|
|
|
|
isNeedAdjustHeight: opts.isNeedAdjustHeight, |
|
|
|
|
isNeedAdjustWidth: opts.isNeedAdjustWidth, |
|
|
|
|
type: "bi.htape", |
|
|
|
|
cls: "bi-border bi-border-radius bi-focus-shadow", |
|
|
|
|
items: [{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.dynamic_date_time_trigger", |
|
|
|
|
min: opts.minDate, |
|
|
|
|
max: opts.maxDate, |
|
|
|
|
allowEdit: opts.allowEdit, |
|
|
|
|
watermark: opts.watermark, |
|
|
|
|
format: opts.format, |
|
|
|
|
type: "bi.icon_button", |
|
|
|
|
cls: "bi-trigger-icon-button date-change-h-font", |
|
|
|
|
width: opts.height - 2, |
|
|
|
|
height: opts.height - 2, |
|
|
|
|
value: opts.value, |
|
|
|
|
ref: function () { |
|
|
|
|
self.trigger = this; |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN, |
|
|
|
|
action: function () { |
|
|
|
|
if (self.combo.isViewVisible()) { |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
} |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_KEY_DOWN, arguments); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_STOP, |
|
|
|
|
action: function () { |
|
|
|
|
if (!self.combo.isViewVisible()) { |
|
|
|
|
self.combo.showView(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK, |
|
|
|
|
action: function () { |
|
|
|
|
self.combo.toggle(); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS, |
|
|
|
|
action: function () { |
|
|
|
|
self.storeTriggerValue = self.trigger.getKey(); |
|
|
|
|
if (!self.combo.isViewVisible()) { |
|
|
|
|
self.combo.showView(); |
|
|
|
|
} |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, |
|
|
|
|
action: function () { |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, |
|
|
|
|
action: function () { |
|
|
|
|
self.storeValue = { |
|
|
|
|
type: BI.DynamicDateTimeCombo.Static, |
|
|
|
|
value: { |
|
|
|
|
year: date.getFullYear(), |
|
|
|
|
month: date.getMonth() + 1 |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_VALID, |
|
|
|
|
action: function () { |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM, |
|
|
|
|
action: function () { |
|
|
|
|
var dateStore = self.storeTriggerValue; |
|
|
|
|
var dateObj = self.trigger.getKey(); |
|
|
|
|
if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { |
|
|
|
|
self.storeValue = self.trigger.getValue(); |
|
|
|
|
self.setValue(self.trigger.getValue()); |
|
|
|
|
} else if (BI.isEmptyString(dateObj)) { |
|
|
|
|
self.storeValue = null; |
|
|
|
|
self.trigger.setValue(); |
|
|
|
|
} |
|
|
|
|
self._checkDynamicValue(self.storeValue); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}] |
|
|
|
|
self.changeIcon = this; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
adjustLength: this.constants.comboAdjustHeight, |
|
|
|
|
popup: { |
|
|
|
|
width: opts.height - 2 |
|
|
|
|
}, { |
|
|
|
|
type: "bi.absolute", |
|
|
|
|
items: [{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.dynamic_date_time_popup", |
|
|
|
|
width: opts.isNeedAdjustWidth ? opts.width : undefined, |
|
|
|
|
supportDynamic: opts.supportDynamic, |
|
|
|
|
behaviors: opts.behaviors, |
|
|
|
|
min: opts.minDate, |
|
|
|
|
max: opts.maxDate, |
|
|
|
|
type: "bi.combo", |
|
|
|
|
cls: "bi-focus-shadow", |
|
|
|
|
destroyWhenHide: true, |
|
|
|
|
container: opts.container, |
|
|
|
|
ref: function () { |
|
|
|
|
self.popup = this; |
|
|
|
|
self.combo = this; |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
self.setValue(); |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
var date = BI.getDate(); |
|
|
|
|
self.setValue({ |
|
|
|
|
type: BI.DynamicDateTimeCombo.Static, |
|
|
|
|
value: { |
|
|
|
|
year: date.getFullYear(), |
|
|
|
|
month: date.getMonth() + 1, |
|
|
|
|
day: date.getDate(), |
|
|
|
|
hour: 0, |
|
|
|
|
minute: 0, |
|
|
|
|
second: 0 |
|
|
|
|
toggle: false, |
|
|
|
|
isNeedAdjustHeight: opts.isNeedAdjustHeight, |
|
|
|
|
isNeedAdjustWidth: opts.isNeedAdjustWidth, |
|
|
|
|
el: { |
|
|
|
|
type: "bi.dynamic_date_time_trigger", |
|
|
|
|
min: opts.minDate, |
|
|
|
|
max: opts.maxDate, |
|
|
|
|
allowEdit: opts.allowEdit, |
|
|
|
|
watermark: opts.watermark, |
|
|
|
|
format: opts.format, |
|
|
|
|
height: opts.height - 2, |
|
|
|
|
value: opts.value, |
|
|
|
|
ref: function () { |
|
|
|
|
self.trigger = this; |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN, |
|
|
|
|
action: function () { |
|
|
|
|
if (self.combo.isViewVisible()) { |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
var value = self.popup.getValue(); |
|
|
|
|
if(self._checkValue(value)) { |
|
|
|
|
self.setValue(value); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_KEY_DOWN, arguments); |
|
|
|
|
} |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimePopup.EVENT_CHANGE, |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_STOP, |
|
|
|
|
action: function () { |
|
|
|
|
if (!self.combo.isViewVisible()) { |
|
|
|
|
self.combo.showView(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK, |
|
|
|
|
action: function () { |
|
|
|
|
self.combo.toggle(); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS, |
|
|
|
|
action: function () { |
|
|
|
|
self.storeTriggerValue = self.trigger.getKey(); |
|
|
|
|
if (!self.combo.isViewVisible()) { |
|
|
|
|
self.combo.showView(); |
|
|
|
|
} |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, |
|
|
|
|
action: function () { |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, |
|
|
|
|
action: function () { |
|
|
|
|
self.storeValue = { |
|
|
|
|
type: BI.DynamicDateTimeCombo.Static, |
|
|
|
|
value: { |
|
|
|
|
year: date.getFullYear(), |
|
|
|
|
month: date.getMonth() + 1 |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_VALID, |
|
|
|
|
action: function () { |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM, |
|
|
|
|
action: function () { |
|
|
|
|
var dateStore = self.storeTriggerValue; |
|
|
|
|
var dateObj = self.trigger.getKey(); |
|
|
|
|
if (self.combo.isViewVisible() || BI.isEqual(dateObj, dateStore)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { |
|
|
|
|
self.storeValue = self.trigger.getValue(); |
|
|
|
|
self.setValue(self.trigger.getValue()); |
|
|
|
|
} else if (BI.isEmptyString(dateObj)) { |
|
|
|
|
self.storeValue = null; |
|
|
|
|
self.trigger.setValue(); |
|
|
|
|
} |
|
|
|
|
self._checkDynamicValue(self.storeValue); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}] |
|
|
|
|
}, |
|
|
|
|
adjustLength: this.constants.comboAdjustHeight, |
|
|
|
|
popup: { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.dynamic_date_time_popup", |
|
|
|
|
width: opts.isNeedAdjustWidth ? opts.width : undefined, |
|
|
|
|
supportDynamic: opts.supportDynamic, |
|
|
|
|
behaviors: opts.behaviors, |
|
|
|
|
min: opts.minDate, |
|
|
|
|
max: opts.maxDate, |
|
|
|
|
ref: function () { |
|
|
|
|
self.popup = this; |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
self.setValue(); |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
var date = BI.getDate(); |
|
|
|
|
self.setValue({ |
|
|
|
|
type: BI.DynamicDateTimeCombo.Static, |
|
|
|
|
value: { |
|
|
|
|
year: date.getFullYear(), |
|
|
|
|
month: date.getMonth() + 1, |
|
|
|
|
day: date.getDate(), |
|
|
|
|
hour: 0, |
|
|
|
|
minute: 0, |
|
|
|
|
second: 0 |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
var value = self.popup.getValue(); |
|
|
|
|
if (self._checkValue(value)) { |
|
|
|
|
self.setValue(value); |
|
|
|
|
} |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimePopup.EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
self.setValue(self.popup.getValue()); |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, |
|
|
|
|
action: function () { |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
|
|
|
|
} |
|
|
|
|
}] |
|
|
|
|
}, |
|
|
|
|
stopPropagation: false |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, |
|
|
|
|
action: function () { |
|
|
|
|
self.setValue(self.popup.getValue()); |
|
|
|
|
self.combo.hideView(); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); |
|
|
|
|
self.popup.setMinDate(opts.minDate); |
|
|
|
|
self.popup.setMaxDate(opts.maxDate); |
|
|
|
|
self.popup.setValue(self.storeValue); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
eventName: BI.DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, |
|
|
|
|
}], |
|
|
|
|
// DEC-4250 和复选下拉一样,点击不收起
|
|
|
|
|
hideChecker: function (e) { |
|
|
|
|
return self.triggerBtn.element.find(e.target).length === 0; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
top: 0, |
|
|
|
|
left: 0, |
|
|
|
|
right: 0, |
|
|
|
|
bottom: 0 |
|
|
|
|
}, { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.icon_button", |
|
|
|
|
cls: "bi-trigger-icon-button date-font", |
|
|
|
|
width: opts.height - 2, |
|
|
|
|
height: opts.height - 2, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.IconButton.EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
|
|
|
|
if (self.combo.isViewVisible()) { |
|
|
|
|
// self.combo.hideView();
|
|
|
|
|
} else { |
|
|
|
|
self.combo.showView(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}] |
|
|
|
|
}, |
|
|
|
|
stopPropagation: false |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, |
|
|
|
|
action: function () { |
|
|
|
|
self.popup.setMinDate(opts.minDate); |
|
|
|
|
self.popup.setMaxDate(opts.maxDate); |
|
|
|
|
self.popup.setValue(self.storeValue); |
|
|
|
|
self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); |
|
|
|
|
} |
|
|
|
|
}], |
|
|
|
|
// DEC-4250 和复选下拉一样,点击不收起
|
|
|
|
|
hideChecker: function (e) { |
|
|
|
|
return self.triggerBtn.element.find(e.target).length === 0; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
top: 0, |
|
|
|
|
left: 0, |
|
|
|
|
right: 0, |
|
|
|
|
bottom: 0 |
|
|
|
|
}, { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.icon_button", |
|
|
|
|
cls: "bi-trigger-icon-button date-font", |
|
|
|
|
width: opts.height, |
|
|
|
|
height: opts.height, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: BI.IconButton.EVENT_CHANGE, |
|
|
|
|
action: function () { |
|
|
|
|
if (self.combo.isViewVisible()) { |
|
|
|
|
// self.combo.hideView();
|
|
|
|
|
} else { |
|
|
|
|
self.combo.showView(); |
|
|
|
|
}], |
|
|
|
|
ref: function () { |
|
|
|
|
self.triggerBtn = this; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}], |
|
|
|
|
ref: function () { |
|
|
|
|
self.triggerBtn = this; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
top: 0, |
|
|
|
|
right: 0 |
|
|
|
|
}] |
|
|
|
|
}], |
|
|
|
|
ref: function (_ref) { |
|
|
|
|
self.comboWrapper = _ref; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
top: 0, |
|
|
|
|
right: 0 |
|
|
|
|
}] |
|
|
|
|
}], |
|
|
|
|
ref: function (_ref) { |
|
|
|
|
self.comboWrapper = _ref; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
top: 1, |
|
|
|
|
left: 1, |
|
|
|
|
right: 1, |
|
|
|
|
bottom: 1 |
|
|
|
|
}] |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -269,7 +280,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
|
|
|
|
|
switch (type) { |
|
|
|
|
case BI.DynamicDateTimeCombo.Dynamic: |
|
|
|
|
this.changeIcon.setVisible(true); |
|
|
|
|
this.comboWrapper.attr("items")[0].width = o.height; |
|
|
|
|
this.comboWrapper.attr("items")[0].width = o.height - 2; |
|
|
|
|
this.comboWrapper.resize(); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
@ -287,6 +298,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
|
|
|
|
|
return BI.isNotEmptyObject(v.value); |
|
|
|
|
case BI.DynamicDateCombo.Static: |
|
|
|
|
var value = v.value || {}; |
|
|
|
|
|
|
|
|
|
return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; |
|
|
|
|
default: |
|
|
|
|
return true; |
|
|
|
|