|
|
|
import { shortcut, Widget, i18nText, CenterAdaptLayout, GridLayout, isNull, isEmptyObject, isEmptyString } from "@/core";
|
|
|
|
import { TextButton } from "@/base";
|
|
|
|
import { DynamicDateTimeSelect } from "../dynamicdatetime";
|
|
|
|
|
|
|
|
@shortcut()
|
|
|
|
export class TimePopup extends Widget {
|
|
|
|
static xtype = "bi.time_popup"
|
|
|
|
|
|
|
|
props = {
|
|
|
|
baseCls: "bi-date-time-popup",
|
|
|
|
height: 68,
|
|
|
|
};
|
|
|
|
|
|
|
|
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
|
|
|
|
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"
|
|
|
|
static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE"
|
|
|
|
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const o = this.options;
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: "bi.vtape",
|
|
|
|
items: [{
|
|
|
|
el: {
|
|
|
|
type: CenterAdaptLayout.xtype,
|
|
|
|
cls: "bi-split-top",
|
|
|
|
items: [{
|
|
|
|
type: DynamicDateTimeSelect.xtype,
|
|
|
|
value: o.value,
|
|
|
|
ref: _ref => {
|
|
|
|
this.timeSelect = _ref;
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
hgap: 10,
|
|
|
|
height: 44,
|
|
|
|
}, {
|
|
|
|
el: {
|
|
|
|
type: GridLayout.xtype,
|
|
|
|
items: [
|
|
|
|
[{
|
|
|
|
type: TextButton.xtype,
|
|
|
|
cls: "bi-high-light bi-split-top",
|
|
|
|
shadow: true,
|
|
|
|
text: i18nText("BI-Basic_Clears"),
|
|
|
|
listeners: [{
|
|
|
|
eventName: TextButton.EVENT_CHANGE,
|
|
|
|
action: () => {
|
|
|
|
this.fireEvent(TimePopup.BUTTON_CLEAR_EVENT_CHANGE);
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
}, {
|
|
|
|
type: TextButton.xtype,
|
|
|
|
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
|
|
|
|
shadow: true,
|
|
|
|
text: i18nText("BI-Basic_Now"),
|
|
|
|
listeners: [{
|
|
|
|
eventName: TextButton.EVENT_CHANGE,
|
|
|
|
action: () => {
|
|
|
|
this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE);
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
}, {
|
|
|
|
type: TextButton.xtype,
|
|
|
|
cls: "bi-high-light bi-split-top",
|
|
|
|
shadow: true,
|
|
|
|
text: i18nText("BI-Basic_OK"),
|
|
|
|
listeners: [{
|
|
|
|
eventName: TextButton.EVENT_CHANGE,
|
|
|
|
action: () => {
|
|
|
|
this.fireEvent(TimePopup.BUTTON_OK_EVENT_CHANGE);
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
}]
|
|
|
|
],
|
|
|
|
},
|
|
|
|
height: 24,
|
|
|
|
}],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
setValue(value) {
|
|
|
|
if (this._checkValueValid(value)) {
|
|
|
|
this.timeSelect.setValue();
|
|
|
|
} else {
|
|
|
|
this.timeSelect.setValue({
|
|
|
|
hour: value.hour,
|
|
|
|
minute: value.minute,
|
|
|
|
second: value.second,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getValue() {
|
|
|
|
return this.timeSelect.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
_checkValueValid(value) {
|
|
|
|
return isNull(value) || isEmptyObject(value) || isEmptyString(value);
|
|
|
|
}
|
|
|
|
}
|