fineui是帆软报表和BI产品线所使用的前端框架。
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.
 
 
 

75 lines
1.7 KiB

import {
shortcut,
extend,
createWidget,
isNull,
getDate,
print
} from "@/core";
import {
Trigger
} from "@/base";
@shortcut()
export class DateTimeTrigger extends Trigger {
static xtype = "bi.date_time_trigger"
_const = {
hgap: 4,
iconWidth: 24,
};
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-date-time-trigger",
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
height: 24,
width: 200,
});
}
_init() {
super._init(...arguments);
const o = this.options,
c = this._const;
this.text = createWidget({
type: "bi.label",
textAlign: "left",
height: o.height,
width: o.width,
hgap: c.hgap,
});
createWidget({
type: "bi.htape",
element: this,
items: [{
el: this.text,
}, {
el: createWidget(),
width: this._const.iconWidth,
}],
});
this.setValue(o.value);
}
_printTime(v) {
return v < 10 ? `0${v}` : v;
}
setValue(v) {
let value = v,
dateStr;
if (isNull(value)) {
value = getDate();
dateStr = print(value, "%Y-%X-%d %H:%M:%S");
} else {
const date = getDate(value.year, value.month - 1, value.day, value.hour, value.minute, value.second);
dateStr = print(date, "%Y-%X-%d %H:%M:%S");
}
this.text.setText(dateStr);
this.text.setTitle(dateStr);
}
}