You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.8 KiB
92 lines
2.8 KiB
/** |
|
* 时间区间 |
|
* qcc |
|
* 2019/2/28 |
|
*/ |
|
|
|
!(function () { |
|
BI.TimePeriods = BI.inherit(BI.Single, { |
|
constants: { |
|
height: 24, |
|
width: 24, |
|
hgap: 15, |
|
offset: -15 |
|
}, |
|
props: { |
|
extraCls: "bi-time-interval", |
|
value: {} |
|
}, |
|
|
|
render: function () { |
|
var self = this, o = this.options; |
|
|
|
return { |
|
type: "bi.horizontal_fill", |
|
columnSize: ["fill", "", "fill"], |
|
items: [{ |
|
el: BI.extend({ |
|
ref: function (_ref) { |
|
self.left = _ref; |
|
} |
|
}, this._createCombo(o.value.start, o.watermark?.start)) |
|
}, { |
|
el: { |
|
type: "bi.label", |
|
height: o.height, |
|
hgap: 5, |
|
text: "-", |
|
ref: function (_ref) { |
|
self.label = _ref; |
|
} |
|
} |
|
}, { |
|
el: BI.extend({ |
|
ref: function (_ref) { |
|
self.right = _ref; |
|
} |
|
}, this._createCombo(o.value.end, o.watermark?.end)) |
|
}] |
|
}; |
|
}, |
|
|
|
_createCombo: function (v, watermark) { |
|
var self = this; |
|
var o = this.options; |
|
return { |
|
type: "bi.time_combo", |
|
value: v, |
|
height: o.height, |
|
watermark: watermark, |
|
listeners: [{ |
|
eventName: BI.TimeCombo.EVENT_BEFORE_POPUPVIEW, |
|
action: function () { |
|
self.left.hidePopupView(); |
|
self.right.hidePopupView(); |
|
} |
|
}, { |
|
eventName: BI.TimeCombo.EVENT_CHANGE, |
|
action: function () { |
|
self.fireEvent(BI.TimePeriods.EVENT_CHANGE); |
|
} |
|
}, { |
|
eventName: BI.TimeCombo.EVENT_CONFIRM, |
|
action: function () { |
|
self.fireEvent(BI.TimePeriods.EVENT_CONFIRM); |
|
} |
|
}] |
|
}; |
|
}, |
|
|
|
setValue: function (date) { |
|
date = date || {}; |
|
this.left.setValue(date.start); |
|
this.right.setValue(date.end); |
|
}, |
|
getValue: function () { |
|
return {start: this.left.getValue(), end: this.right.getValue()}; |
|
} |
|
}); |
|
BI.TimePeriods.EVENT_CONFIRM = "EVENT_CONFIRM"; |
|
BI.TimePeriods.EVENT_CHANGE = "EVENT_CHANGE"; |
|
BI.shortcut("bi.time_periods", BI.TimePeriods); |
|
})();
|
|
|