Browse Source
Merge in VISUAL/fineui from ~ZHENFEI.LI/fineui:es6 to es6 * commit '1c1b262c9e168bace4fdeb570ee308e55805b60a': KERNEL-14087 refactor: widget/dynamicdate、datepane、datetime、datetimepane、dynamicdatetimees6
Zhenfei.Li-李振飞
2 years ago
25 changed files with 2688 additions and 2501 deletions
@ -1,185 +1,207 @@
|
||||
/** |
||||
* Created by zcf on 2017/2/20. |
||||
*/ |
||||
BI.StaticDatePaneCard = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
var conf = BI.StaticDatePaneCard.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
import { shortcut, Widget, extend, createWidget, bind, isNull, each, isNotEmptyString, getDate, getMonthDays } from "@/core"; |
||||
import { DatePicker, DateCalendarPopup } from "../date/calendar"; |
||||
import { Calendar } from "@/case"; |
||||
import { Navigation } from "@/base"; |
||||
|
||||
@shortcut() |
||||
export class StaticDatePaneCard extends Widget { |
||||
static xtype = "bi.static_date_pane_card"; |
||||
|
||||
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = |
||||
"EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"; |
||||
|
||||
_defaultConfig() { |
||||
const conf = super._defaultConfig(...arguments); |
||||
|
||||
return extend(conf, { |
||||
baseCls: "bi-date-pane", |
||||
min: "1900-01-01", // 最小日期
|
||||
max: "2099-12-31", // 最大日期
|
||||
selectedTime: null |
||||
selectedTime: null, |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
BI.StaticDatePaneCard.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
} |
||||
|
||||
_init() { |
||||
super._init(...arguments); |
||||
const o = this.options; |
||||
|
||||
this.today = BI.getDate(); |
||||
this.today = getDate(); |
||||
this._year = this.today.getFullYear(); |
||||
this._month = this.today.getMonth() + 1; |
||||
|
||||
this.selectedTime = o.selectedTime || { |
||||
year: this._year, |
||||
month: this._month |
||||
month: this._month, |
||||
}; |
||||
|
||||
this.datePicker = BI.createWidget({ |
||||
this.datePicker = createWidget({ |
||||
type: "bi.date_picker", |
||||
behaviors: o.behaviors, |
||||
min: o.min, |
||||
max: o.max |
||||
max: o.max, |
||||
}); |
||||
this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { |
||||
var value = self.datePicker.getValue(); |
||||
var monthDay = BI.getMonthDays(BI.getDate(value.year, value.month - 1, 1)); |
||||
var day = self.selectedTime.day || 0; |
||||
this.datePicker.on(DatePicker.EVENT_CHANGE, () => { |
||||
const value = this.datePicker.getValue(); |
||||
const monthDay = getMonthDays( |
||||
getDate(value.year, value.month - 1, 1) |
||||
); |
||||
let day = this.selectedTime.day || 0; |
||||
if (day > monthDay) { |
||||
day = monthDay; |
||||
} |
||||
self.selectedTime = { |
||||
this.selectedTime = { |
||||
year: value.year, |
||||
month: value.month |
||||
month: value.month, |
||||
}; |
||||
day !== 0 && (self.selectedTime.day = day); |
||||
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); |
||||
self.calendar.setValue(self.selectedTime); |
||||
day !== 0 && self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); |
||||
}); |
||||
this.datePicker.on(BI.DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, function () { |
||||
self.fireEvent(BI.StaticDatePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
||||
day !== 0 && (this.selectedTime.day = day); |
||||
this.calendar.setSelect( |
||||
Calendar.getPageByDateJSON(this.selectedTime) |
||||
); |
||||
this.calendar.setValue(this.selectedTime); |
||||
day !== 0 && this.fireEvent(DateCalendarPopup.EVENT_CHANGE); |
||||
}); |
||||
this.datePicker.on( |
||||
DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, |
||||
() => { |
||||
this.fireEvent( |
||||
StaticDatePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW |
||||
); |
||||
} |
||||
); |
||||
|
||||
this.calendar = BI.createWidget({ |
||||
this.calendar = createWidget({ |
||||
direction: "custom", |
||||
// logic: {
|
||||
// dynamic: false
|
||||
// },
|
||||
type: "bi.navigation", |
||||
tab: this.datePicker, |
||||
cardCreator: BI.bind(this._createNav, this) |
||||
cardCreator: bind(this._createNav, this), |
||||
}); |
||||
this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { |
||||
self.selectedTime = self.calendar.getValue(); |
||||
self.calendar.empty(); |
||||
self.setValue(self.selectedTime); |
||||
self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); |
||||
this.calendar.on(Navigation.EVENT_CHANGE, () => { |
||||
this.selectedTime = this.calendar.getValue(); |
||||
this.calendar.empty(); |
||||
this.setValue(this.selectedTime); |
||||
this.fireEvent(DateCalendarPopup.EVENT_CHANGE); |
||||
}); |
||||
this.setValue(o.selectedTime); |
||||
|
||||
BI.createWidget({ |
||||
createWidget({ |
||||
type: "bi.vtape", |
||||
element: this, |
||||
items: [{ |
||||
items: [ |
||||
{ |
||||
el: this.datePicker, |
||||
height: 40 |
||||
}, this.calendar], |
||||
hgap: 10 |
||||
height: 40, |
||||
}, |
||||
this.calendar |
||||
], |
||||
hgap: 10, |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
createWidget({ |
||||
type: "bi.absolute", |
||||
element: this, |
||||
items: [{ |
||||
items: [ |
||||
{ |
||||
el: { |
||||
type: "bi.layout", |
||||
cls: "bi-split-top" |
||||
cls: "bi-split-top", |
||||
}, |
||||
height: 1, |
||||
top: 40, |
||||
left: 0, |
||||
right: 0 |
||||
}] |
||||
right: 0, |
||||
} |
||||
], |
||||
}); |
||||
} |
||||
|
||||
}, |
||||
|
||||
_createNav: function (v) { |
||||
var date = BI.Calendar.getDateJSONByPage(v); |
||||
var calendar = BI.createWidget({ |
||||
_createNav(v) { |
||||
const date = Calendar.getDateJSONByPage(v); |
||||
const calendar = createWidget({ |
||||
type: "bi.calendar", |
||||
logic: { |
||||
dynamic: false |
||||
dynamic: false, |
||||
}, |
||||
min: this.options.min, |
||||
max: this.options.max, |
||||
year: date.year, |
||||
month: date.month, |
||||
day: this.selectedTime.day |
||||
day: this.selectedTime.day, |
||||
}); |
||||
|
||||
return calendar; |
||||
}, |
||||
} |
||||
|
||||
_getNewCurrentDate() { |
||||
const today = getDate(); |
||||
|
||||
_getNewCurrentDate: function () { |
||||
var today = BI.getDate(); |
||||
return { |
||||
year: today.getFullYear(), |
||||
month: today.getMonth() + 1 |
||||
month: today.getMonth() + 1, |
||||
}; |
||||
}, |
||||
} |
||||
|
||||
_setCalenderValue: function (date) { |
||||
this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date)); |
||||
_setCalenderValue(date) { |
||||
this.calendar.setSelect(Calendar.getPageByDateJSON(date)); |
||||
this.calendar.setValue(date); |
||||
this.selectedTime = date; |
||||
}, |
||||
} |
||||
|
||||
_setDatePicker: function (timeOb) { |
||||
if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) { |
||||
_setDatePicker(timeOb) { |
||||
if (isNull(timeOb) || isNull(timeOb.year) || isNull(timeOb.month)) { |
||||
this.datePicker.setValue(this._getNewCurrentDate()); |
||||
} else { |
||||
this.datePicker.setValue(timeOb); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
_setCalendar: function (timeOb) { |
||||
if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) { |
||||
_setCalendar(timeOb) { |
||||
if (isNull(timeOb) || isNull(timeOb.day)) { |
||||
this.calendar.empty(); |
||||
this._setCalenderValue(this._getNewCurrentDate()); |
||||
} else { |
||||
this._setCalenderValue(timeOb); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
_checkMin: function () { |
||||
var o = this.options; |
||||
BI.each(this.calendar.getAllCard(), function (idx, calendar) { |
||||
_checkMin() { |
||||
const o = this.options; |
||||
each(this.calendar.getAllCard(), (idx, calendar) => { |
||||
calendar.setMinDate(o.min); |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_checkMax: function () { |
||||
var o = this.options; |
||||
BI.each(this.calendar.getAllCard(), function (idx, calendar) { |
||||
_checkMax() { |
||||
const o = this.options; |
||||
each(this.calendar.getAllCard(), (idx, calendar) => { |
||||
calendar.setMaxDate(o.max); |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
setMinDate: function (minDate) { |
||||
if (BI.isNotEmptyString(this.options.min)) { |
||||
setMinDate(minDate) { |
||||
if (isNotEmptyString(this.options.min)) { |
||||
this.options.min = minDate; |
||||
this.datePicker.setMinDate(minDate); |
||||
this._checkMin(); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setMaxDate: function (maxDate) { |
||||
if (BI.isNotEmptyString(this.options.max)) { |
||||
setMaxDate(maxDate) { |
||||
if (isNotEmptyString(this.options.max)) { |
||||
this.options.max = maxDate; |
||||
this.datePicker.setMaxDate(maxDate); |
||||
this._checkMax(); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setValue: function (timeOb) { |
||||
setValue(timeOb) { |
||||
this._setDatePicker(timeOb); |
||||
this._setCalendar(timeOb); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.selectedTime; |
||||
} |
||||
|
||||
}); |
||||
BI.StaticDatePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW" |
||||
BI.shortcut("bi.static_date_pane_card", BI.StaticDatePaneCard); |
||||
} |
||||
|
@ -0,0 +1,2 @@
|
||||
export { StaticDatePaneCard } from "./card.static.datepane"; |
||||
export { DynamicDatePane } from "./datepane"; |
@ -1,113 +1,121 @@
|
||||
/** |
||||
* Created by Urthur on 2017/7/14. |
||||
*/ |
||||
BI.DateTimePopup = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), { |
||||
import { shortcut, Widget, extend, createWidget, i18nText, isNull, getDate } from "@/core"; |
||||
import { TextButton } from "@/base"; |
||||
import { DateCalendarPopup } from "../date/calendar"; |
||||
|
||||
@shortcut() |
||||
export class DateTimePopup extends Widget { |
||||
static xtype = "bi.date_time_popup" |
||||
|
||||
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE" |
||||
static BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE" |
||||
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE" |
||||
|
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
baseCls: "bi-date-time-popup", |
||||
width: 268, |
||||
height: 374 |
||||
height: 374, |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
BI.DateTimePopup.superclass._init.apply(this, arguments); |
||||
var self = this, opts = this.options; |
||||
this.cancelButton = BI.createWidget({ |
||||
} |
||||
|
||||
_init() { |
||||
super._init(...arguments); |
||||
const opts = this.options; |
||||
this.cancelButton = createWidget({ |
||||
type: "bi.text_button", |
||||
cls: "multidate-popup-button bi-border-top bi-border-right", |
||||
shadow: true, |
||||
text: BI.i18nText("BI-Basic_Cancel") |
||||
text: i18nText("BI-Basic_Cancel"), |
||||
}); |
||||
this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE); |
||||
this.cancelButton.on(TextButton.EVENT_CHANGE, () => { |
||||
this.fireEvent(DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE); |
||||
}); |
||||
|
||||
this.okButton = BI.createWidget({ |
||||
this.okButton = createWidget({ |
||||
type: "bi.text_button", |
||||
cls: "multidate-popup-button bi-border-top", |
||||
shadow: true, |
||||
text: BI.i18nText("BI-Basic_OK") |
||||
text: i18nText("BI-Basic_OK"), |
||||
}); |
||||
this.okButton.on(BI.TextButton.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE); |
||||
this.okButton.on(TextButton.EVENT_CHANGE, () => { |
||||
this.fireEvent(DateTimePopup.BUTTON_OK_EVENT_CHANGE); |
||||
}); |
||||
|
||||
this.dateCombo = BI.createWidget({ |
||||
this.dateCombo = createWidget({ |
||||
type: "bi.date_calendar_popup", |
||||
behaviors: opts.behaviors, |
||||
min: self.options.min, |
||||
max: self.options.max |
||||
min: this.options.min, |
||||
max: this.options.max, |
||||
}); |
||||
self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { |
||||
self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); |
||||
this.dateCombo.on(DateCalendarPopup.EVENT_CHANGE, () => { |
||||
this.fireEvent(DateTimePopup.CALENDAR_EVENT_CHANGE); |
||||
}); |
||||
|
||||
this.dateButton = BI.createWidget({ |
||||
this.dateButton = createWidget({ |
||||
type: "bi.grid", |
||||
items: [[this.cancelButton, this.okButton]] |
||||
items: [ |
||||
[this.cancelButton, this.okButton] |
||||
], |
||||
}); |
||||
BI.createWidget({ |
||||
createWidget({ |
||||
element: this, |
||||
type: "bi.vtape", |
||||
items: [{ |
||||
el: this.dateCombo |
||||
el: this.dateCombo, |
||||
}, { |
||||
el: { |
||||
type: "bi.center_adapt", |
||||
cls: "bi-split-top", |
||||
items: [{ |
||||
type: "bi.dynamic_date_time_select", |
||||
ref: function (_ref) { |
||||
self.timeSelect = _ref; |
||||
} |
||||
}] |
||||
ref: _ref => { |
||||
this.timeSelect = _ref; |
||||
}, |
||||
height: 50 |
||||
}], |
||||
}, |
||||
height: 50, |
||||
}, { |
||||
el: this.dateButton, |
||||
height: 30 |
||||
}] |
||||
height: 30, |
||||
}], |
||||
}); |
||||
this.setValue(opts.value); |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
var value = v, date; |
||||
if (BI.isNull(value)) { |
||||
date = BI.getDate(); |
||||
setValue(v) { |
||||
const value = v; |
||||
let date; |
||||
if (isNull(value)) { |
||||
date = getDate(); |
||||
this.dateCombo.setValue({ |
||||
year: date.getFullYear(), |
||||
month: date.getMonth() + 1, |
||||
day: date.getDate() |
||||
day: date.getDate(), |
||||
}); |
||||
this.timeSelect.setValue({ |
||||
hour: date.getHours(), |
||||
minute: date.getMinutes(), |
||||
second: date.getSeconds() |
||||
second: date.getSeconds(), |
||||
}); |
||||
} else { |
||||
this.dateCombo.setValue({ |
||||
year: value.year, |
||||
month: value.month, |
||||
day: value.day |
||||
day: value.day, |
||||
}); |
||||
this.timeSelect.setValue({ |
||||
hour: value.hour, |
||||
minute: value.minute, |
||||
second: value.second |
||||
second: value.second, |
||||
}); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
return BI.extend({ |
||||
getValue() { |
||||
return extend({ |
||||
year: this.dateCombo.getValue().year, |
||||
month: this.dateCombo.getValue().month, |
||||
day: this.dateCombo.getValue().day |
||||
day: this.dateCombo.getValue().day, |
||||
}, this.timeSelect.getValue()); |
||||
} |
||||
}); |
||||
BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; |
||||
BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE"; |
||||
BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; |
||||
BI.shortcut("bi.date_time_popup", BI.DateTimePopup); |
||||
} |
||||
|
@ -1,63 +1,75 @@
|
||||
/** |
||||
* Created by Urthur on 2017/7/14. |
||||
*/ |
||||
BI.DateTimeTrigger = BI.inherit(BI.Trigger, { |
||||
_const: { |
||||
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 |
||||
}, |
||||
iconWidth: 24, |
||||
}; |
||||
|
||||
_defaultConfig: function () { |
||||
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), { |
||||
_defaultConfig() { |
||||
return extend(super._defaultConfig(...arguments), { |
||||
extraCls: "bi-date-time-trigger", |
||||
min: "1900-01-01", // 最小日期
|
||||
max: "2099-12-31", // 最大日期
|
||||
height: 24, |
||||
width: 200 |
||||
width: 200, |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
BI.DateTimeTrigger.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options, c = this._const; |
||||
this.text = BI.createWidget({ |
||||
} |
||||
|
||||
_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 |
||||
hgap: c.hgap, |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
createWidget({ |
||||
type: "bi.htape", |
||||
element: this, |
||||
items: [{ |
||||
el: this.text |
||||
el: this.text, |
||||
}, { |
||||
el: BI.createWidget(), |
||||
width: this._const.iconWidth |
||||
}] |
||||
el: createWidget(), |
||||
width: this._const.iconWidth, |
||||
}], |
||||
}); |
||||
this.setValue(o.value); |
||||
}, |
||||
|
||||
_printTime: function (v) { |
||||
return v < 10 ? "0" + v : v; |
||||
}, |
||||
|
||||
setValue: function (v) { |
||||
var self = this; |
||||
var value = v, dateStr; |
||||
if(BI.isNull(value)) { |
||||
value = BI.getDate(); |
||||
dateStr = BI.print(value, "%Y-%X-%d %H:%M:%S"); |
||||
} else { |
||||
var date = BI.getDate(value.year, value.month - 1, value.day, value.hour, value.minute, value.second); |
||||
dateStr = BI.print(date, "%Y-%X-%d %H:%M:%S"); |
||||
} |
||||
|
||||
_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); |
||||
} |
||||
|
||||
}); |
||||
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger); |
||||
} |
||||
|
@ -0,0 +1,3 @@
|
||||
export { DateTimeCombo } from "./datetime.combo"; |
||||
export { DateTimePopup } from "./datetime.popup"; |
||||
export { DateTimeTrigger } from "./datetime.trigger"; |
@ -1,205 +1,216 @@
|
||||
BI.StaticDateTimePaneCard = BI.inherit(BI.Widget, { |
||||
_defaultConfig: function () { |
||||
var conf = BI.StaticDateTimePaneCard.superclass._defaultConfig.apply(this, arguments); |
||||
return BI.extend(conf, { |
||||
import { shortcut, Widget, extend, getDate, createWidget, bind, isNull, each, isNotEmptyString, getMonthDays } from "@/core"; |
||||
import { DatePicker, DateCalendarPopup } from "../date/calendar"; |
||||
import { Calendar } from "@/case"; |
||||
import { Navigation } from "@/base"; |
||||
import { DynamicDateTimeSelect } from "../dynamicdatetime/dynamicdatetime.timeselect"; |
||||
|
||||
@shortcut() |
||||
export class StaticDateTimePaneCard extends Widget { |
||||
static xtype = "bi.static_date_time_pane_card" |
||||
|
||||
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW" |
||||
|
||||
_defaultConfig() { |
||||
const conf = super._defaultConfig(...arguments); |
||||
|
||||
return extend(conf, { |
||||
baseCls: "bi-date-time-pane", |
||||
min: "1900-01-01", // 最小日期
|
||||
max: "2099-12-31", // 最大日期
|
||||
selectedTime: null |
||||
selectedTime: null, |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
BI.StaticDateTimePaneCard.superclass._init.apply(this, arguments); |
||||
var self = this, o = this.options; |
||||
} |
||||
|
||||
_init() { |
||||
super._init(...arguments); |
||||
const o = this.options; |
||||
|
||||
this.today = BI.getDate(); |
||||
this.today = getDate(); |
||||
this._year = this.today.getFullYear(); |
||||
this._month = this.today.getMonth() + 1; |
||||
|
||||
this.selectedTime = o.selectedTime || { |
||||
year: this._year, |
||||
month: this._month |
||||
month: this._month, |
||||
}; |
||||
|
||||
this.datePicker = BI.createWidget({ |
||||
this.datePicker = createWidget({ |
||||
type: "bi.date_picker", |
||||
behaviors: o.behaviors, |
||||
min: o.min, |
||||
max: o.max |
||||
max: o.max, |
||||
}); |
||||
this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { |
||||
var value = self.datePicker.getValue(); |
||||
var monthDay = BI.getMonthDays(BI.getDate(value.year, value.month - 1, 1)); |
||||
var day = self.selectedTime.day || 0; |
||||
this.datePicker.on(DatePicker.EVENT_CHANGE, () => { |
||||
const value = this.datePicker.getValue(); |
||||
const monthDay = getMonthDays(getDate(value.year, value.month - 1, 1)); |
||||
let day = this.selectedTime.day || 0; |
||||
if (day > monthDay) { |
||||
day = monthDay; |
||||
} |
||||
self.selectedTime = BI.extend(self.selectedTime, { |
||||
this.selectedTime = extend(this.selectedTime, { |
||||
year: value.year, |
||||
month: value.month |
||||
month: value.month, |
||||
}); |
||||
day !== 0 && (self.selectedTime.day = day); |
||||
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); |
||||
self.calendar.setValue(self.selectedTime); |
||||
day !== 0 && self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); |
||||
day !== 0 && (this.selectedTime.day = day); |
||||
this.calendar.setSelect(Calendar.getPageByDateJSON(this.selectedTime)); |
||||
this.calendar.setValue(this.selectedTime); |
||||
day !== 0 && this.fireEvent(DateCalendarPopup.EVENT_CHANGE); |
||||
}); |
||||
|
||||
this.datePicker.on(BI.DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, function () { |
||||
self.fireEvent(BI.StaticDateTimePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
||||
this.datePicker.on(DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, () => { |
||||
this.fireEvent(StaticDateTimePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
||||
}); |
||||
|
||||
this.calendar = BI.createWidget({ |
||||
this.calendar = createWidget({ |
||||
direction: "custom", |
||||
// logic: {
|
||||
// dynamic: false
|
||||
// },
|
||||
type: "bi.navigation", |
||||
tab: this.datePicker, |
||||
cardCreator: BI.bind(this._createNav, this) |
||||
cardCreator: bind(this._createNav, this), |
||||
}); |
||||
this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { |
||||
self.selectedTime = BI.extend(self.calendar.getValue(), self.timeSelect.getValue()); |
||||
self.calendar.empty(); |
||||
self.setValue(self.selectedTime); |
||||
self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); |
||||
this.calendar.on(Navigation.EVENT_CHANGE, () => { |
||||
this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue()); |
||||
this.calendar.empty(); |
||||
this.setValue(this.selectedTime); |
||||
this.fireEvent(DateCalendarPopup.EVENT_CHANGE); |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
createWidget({ |
||||
type: "bi.vtape", |
||||
element: this, |
||||
hgap: 10, |
||||
items: [{ |
||||
el: this.datePicker, |
||||
height: 40 |
||||
height: 40, |
||||
}, this.calendar, { |
||||
el: { |
||||
type: "bi.dynamic_date_time_select", |
||||
cls: "bi-split-top", |
||||
ref: function () { |
||||
self.timeSelect = this; |
||||
ref: _ref => { |
||||
this.timeSelect = _ref; |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.DynamicDateTimeSelect.EVENT_CONFIRM, |
||||
action: function () { |
||||
self.selectedTime = BI.extend(self.calendar.getValue(), self.timeSelect.getValue()); |
||||
self.fireEvent("EVENT_CHANGE"); |
||||
} |
||||
}] |
||||
eventName: DynamicDateTimeSelect.EVENT_CONFIRM, |
||||
action: () => { |
||||
this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue()); |
||||
this.fireEvent("EVENT_CHANGE"); |
||||
}, |
||||
}], |
||||
}, |
||||
height: 40 |
||||
}] |
||||
height: 40, |
||||
}], |
||||
}); |
||||
|
||||
BI.createWidget({ |
||||
createWidget({ |
||||
type: "bi.absolute", |
||||
element: this, |
||||
items: [{ |
||||
el: { |
||||
type: "bi.layout", |
||||
cls: "bi-split-top" |
||||
cls: "bi-split-top", |
||||
}, |
||||
height: 1, |
||||
top: 40, |
||||
left: 0, |
||||
right: 0 |
||||
}] |
||||
right: 0, |
||||
}], |
||||
}); |
||||
this.setValue(o.selectedTime); |
||||
} |
||||
|
||||
}, |
||||
|
||||
_createNav: function (v) { |
||||
var date = BI.Calendar.getDateJSONByPage(v); |
||||
var calendar = BI.createWidget({ |
||||
_createNav(v) { |
||||
const date = Calendar.getDateJSONByPage(v); |
||||
const calendar = createWidget({ |
||||
type: "bi.calendar", |
||||
logic: { |
||||
dynamic: false |
||||
dynamic: false, |
||||
}, |
||||
min: this.options.min, |
||||
max: this.options.max, |
||||
year: date.year, |
||||
month: date.month, |
||||
day: this.selectedTime.day |
||||
day: this.selectedTime.day, |
||||
}); |
||||
|
||||
return calendar; |
||||
}, |
||||
} |
||||
|
||||
_getNewCurrentDate() { |
||||
const today = getDate(); |
||||
|
||||
_getNewCurrentDate: function () { |
||||
var today = BI.getDate(); |
||||
return { |
||||
year: today.getFullYear(), |
||||
month: today.getMonth() + 1 |
||||
month: today.getMonth() + 1, |
||||
}; |
||||
}, |
||||
} |
||||
|
||||
_setCalenderValue: function (date) { |
||||
this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date)); |
||||
_setCalenderValue(date) { |
||||
this.calendar.setSelect(Calendar.getPageByDateJSON(date)); |
||||
this.calendar.setValue(date); |
||||
this.selectedTime = BI.extend({}, this.timeSelect.getValue(), date); |
||||
}, |
||||
this.selectedTime = extend({}, this.timeSelect.getValue(), date); |
||||
} |
||||
|
||||
_setDatePicker: function (timeOb) { |
||||
if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) { |
||||
_setDatePicker(timeOb) { |
||||
if (isNull(timeOb) || isNull(timeOb.year) || isNull(timeOb.month)) { |
||||
this.datePicker.setValue(this._getNewCurrentDate()); |
||||
} else { |
||||
this.datePicker.setValue(timeOb); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
_setCalendar: function (timeOb) { |
||||
if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) { |
||||
_setCalendar(timeOb) { |
||||
if (isNull(timeOb) || isNull(timeOb.day)) { |
||||
this.calendar.empty(); |
||||
this._setCalenderValue(this._getNewCurrentDate()); |
||||
} else { |
||||
this._setCalenderValue(timeOb); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
_checkMin: function () { |
||||
var o = this.options; |
||||
BI.each(this.calendar.getAllCard(), function (idx, calendar) { |
||||
_checkMin() { |
||||
const o = this.options; |
||||
each(this.calendar.getAllCard(), (idx, calendar) => { |
||||
calendar.setMinDate(o.min); |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
_checkMax: function () { |
||||
var o = this.options; |
||||
BI.each(this.calendar.getAllCard(), function (idx, calendar) { |
||||
_checkMax() { |
||||
const o = this.options; |
||||
each(this.calendar.getAllCard(), (idx, calendar) => { |
||||
calendar.setMaxDate(o.max); |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
setMinDate: function (minDate) { |
||||
if (BI.isNotEmptyString(this.options.min)) { |
||||
setMinDate(minDate) { |
||||
if (isNotEmptyString(this.options.min)) { |
||||
this.options.min = minDate; |
||||
this.datePicker.setMinDate(minDate); |
||||
this._checkMin(); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setMaxDate: function (maxDate) { |
||||
if (BI.isNotEmptyString(this.options.max)) { |
||||
setMaxDate(maxDate) { |
||||
if (isNotEmptyString(this.options.max)) { |
||||
this.options.max = maxDate; |
||||
this.datePicker.setMaxDate(maxDate); |
||||
this._checkMax(); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setValue: function (timeOb) { |
||||
setValue(timeOb) { |
||||
timeOb = timeOb || {}; |
||||
this._setDatePicker(timeOb); |
||||
this._setCalendar(timeOb); |
||||
this.timeSelect.setValue({ |
||||
hour: timeOb.hour, |
||||
minute: timeOb.minute, |
||||
second: timeOb.second |
||||
second: timeOb.second, |
||||
}); |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return this.selectedTime; |
||||
} |
||||
|
||||
}); |
||||
BI.StaticDateTimePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"; |
||||
BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard); |
||||
} |
||||
|
@ -0,0 +1,2 @@
|
||||
export { StaticDateTimePaneCard } from "./card.static.datetimepane"; |
||||
export { DynamicDateTimePane } from "./datetimepane"; |
@ -1,117 +1,119 @@
|
||||
!(function () { |
||||
BI.DynamicDateHelper = {}; |
||||
BI.extend(BI.DynamicDateHelper, { |
||||
getCalculation: function (obj) { |
||||
var date = BI.getDate(); |
||||
import { isNotNull, parseInt, getDate, i18nText, size, getOffsetQuarter, getOffsetMonth, getOffsetDate, getLastDateOfMonth, getWeekStartDate, getWeekEndDate, getQuarterStartDate, getQuarterEndDate, print } from "@/core"; |
||||
import { DynamicDateCard } from "./dynamicdate.card"; |
||||
|
||||
export const DynamicDateHelper = { |
||||
getCalculation (obj) { |
||||
const date = getDate(); |
||||
|
||||
return this.getCalculationByDate(date, obj); |
||||
}, |
||||
|
||||
getDescription: function (obj) { |
||||
var value = ""; |
||||
var endText = ""; |
||||
if(BI.isNotNull(obj.year)) { |
||||
if(BI.parseInt(obj.year) !== 0) { |
||||
value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); |
||||
getDescription (obj) { |
||||
let value = ""; |
||||
let endText = ""; |
||||
if (isNotNull(obj.year)) { |
||||
if (parseInt(obj.year) !== 0) { |
||||
value += Math.abs(obj.year) + i18nText("BI-Basic_Year") + (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind")); |
||||
} |
||||
endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position); |
||||
endText = getPositionText(i18nText("BI-Basic_Year"), obj.position); |
||||
} |
||||
if(BI.isNotNull(obj.quarter)) { |
||||
if(BI.parseInt(obj.quarter) !== 0) { |
||||
value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); |
||||
if (isNotNull(obj.quarter)) { |
||||
if (parseInt(obj.quarter) !== 0) { |
||||
value += Math.abs(obj.quarter) + i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind")); |
||||
} |
||||
endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position); |
||||
endText = getPositionText(i18nText("BI-Basic_Single_Quarter"), obj.position); |
||||
} |
||||
if(BI.isNotNull(obj.month)) { |
||||
if(BI.parseInt(obj.month) !== 0) { |
||||
value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); |
||||
if (isNotNull(obj.month)) { |
||||
if (parseInt(obj.month) !== 0) { |
||||
value += Math.abs(obj.month) + i18nText("BI-Basic_Month") + (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind")); |
||||
} |
||||
endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position); |
||||
endText = getPositionText(i18nText("BI-Basic_Month"), obj.position); |
||||
} |
||||
if(BI.isNotNull(obj.week)) { |
||||
if(BI.parseInt(obj.week) !== 0) { |
||||
value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); |
||||
if (isNotNull(obj.week)) { |
||||
if (parseInt(obj.week) !== 0) { |
||||
value += Math.abs(obj.week) + i18nText("BI-Basic_Week") + (obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind")); |
||||
} |
||||
endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position); |
||||
endText = getPositionText(i18nText("BI-Basic_Week"), obj.position); |
||||
} |
||||
if(BI.isNotNull(obj.day)) { |
||||
if(BI.parseInt(obj.day) !== 0) { |
||||
value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); |
||||
if (isNotNull(obj.day)) { |
||||
if (parseInt(obj.day) !== 0) { |
||||
value += Math.abs(obj.day) + i18nText("BI-Basic_Day") + (obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind")); |
||||
} |
||||
endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : ""; |
||||
endText = size(obj) === 1 ? getPositionText(i18nText("BI-Basic_Month"), obj.position) : ""; |
||||
} |
||||
if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) { |
||||
value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); |
||||
if (isNotNull(obj.workDay) && parseInt(obj.workDay) !== 0) { |
||||
value += Math.abs(obj.workDay) + i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind")); |
||||
} |
||||
|
||||
return value + endText; |
||||
|
||||
function getPositionText (baseText, position) { |
||||
switch (position) { |
||||
case BI.DynamicDateCard.OFFSET.BEGIN: |
||||
return baseText + BI.i18nText("BI-Basic_Begin_Start"); |
||||
case BI.DynamicDateCard.OFFSET.END: |
||||
return baseText + BI.i18nText("BI-Basic_End_Stop"); |
||||
case BI.DynamicDateCard.OFFSET.CURRENT: |
||||
case DynamicDateCard.OFFSET.BEGIN: |
||||
return baseText + i18nText("BI-Basic_Begin_Start"); |
||||
case DynamicDateCard.OFFSET.END: |
||||
return baseText + i18nText("BI-Basic_End_Stop"); |
||||
case DynamicDateCard.OFFSET.CURRENT: |
||||
default: |
||||
return BI.i18nText("BI-Basic_Current_Day"); |
||||
return i18nText("BI-Basic_Current_Day"); |
||||
} |
||||
} |
||||
}, |
||||
|
||||
getCalculationByDate: function (date, obj) { |
||||
if (BI.isNotNull(obj.year)) { |
||||
date = BI.getDate((date.getFullYear() + BI.parseInt(obj.year)), date.getMonth(), date.getDate()); |
||||
getCalculationByDate (date, obj) { |
||||
if (isNotNull(obj.year)) { |
||||
date = getDate((date.getFullYear() + parseInt(obj.year)), date.getMonth(), date.getDate()); |
||||
} |
||||
if (BI.isNotNull(obj.quarter)) { |
||||
date = BI.getOffsetQuarter(date, BI.parseInt(obj.quarter)); |
||||
if (isNotNull(obj.quarter)) { |
||||
date = getOffsetQuarter(date, parseInt(obj.quarter)); |
||||
} |
||||
if (BI.isNotNull(obj.month)) { |
||||
date = BI.getOffsetMonth(date, BI.parseInt(obj.month)); |
||||
if (isNotNull(obj.month)) { |
||||
date = getOffsetMonth(date, parseInt(obj.month)); |
||||
} |
||||
if (BI.isNotNull(obj.week)) { |
||||
date = BI.getOffsetDate(date, BI.parseInt(obj.week) * 7); |
||||
if (isNotNull(obj.week)) { |
||||
date = getOffsetDate(date, parseInt(obj.week) * 7); |
||||
} |
||||
if (BI.isNotNull(obj.day)) { |
||||
date = BI.getOffsetDate(date, BI.parseInt(obj.day)); |
||||
if (isNotNull(obj.day)) { |
||||
date = getOffsetDate(date, parseInt(obj.day)); |
||||
} |
||||
if (BI.isNotNull(obj.workDay)) { |
||||
if (isNotNull(obj.workDay)) { |
||||
// 配置了节假日就按照节假日计算工作日偏移,否则按正常的天去算
|
||||
if(BI.isNotNull(BI.holidays)) { |
||||
var count = Math.abs(obj.workDay); |
||||
for (var i = 0; i < count; i++) { |
||||
date = BI.getOffsetDate(date, obj.workDay < 0 ? -1 : 1); |
||||
if(BI.isNotNull(BI.holidays[BI.print(date, "%Y-%X-%d")])) { |
||||
if (isNotNull(BI.holidays)) { |
||||
const count = Math.abs(obj.workDay); |
||||
for (let i = 0; i < count; i++) { |
||||
date = getOffsetDate(date, obj.workDay < 0 ? -1 : 1); |
||||
if (isNotNull(BI.holidays[print(date, "%Y-%X-%d")])) { |
||||
i--; |
||||
} |
||||
} |
||||
} else { |
||||
date = BI.getOffsetDate(date, BI.parseInt(obj.workDay)); |
||||
date = getOffsetDate(date, parseInt(obj.workDay)); |
||||
} |
||||
} |
||||
if (BI.isNotNull(obj.position) && obj.position !== BI.DynamicDateCard.OFFSET.CURRENT) { |
||||
if (isNotNull(obj.position) && obj.position !== DynamicDateCard.OFFSET.CURRENT) { |
||||
date = this.getBeginDate(date, obj); |
||||
} |
||||
|
||||
return BI.getDate(date.getFullYear(), date.getMonth(), date.getDate()); |
||||
return getDate(date.getFullYear(), date.getMonth(), date.getDate()); |
||||
}, |
||||
|
||||
getBeginDate: function (date, obj) { |
||||
if (BI.isNotNull(obj.day)) { |
||||
return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), date.getMonth(), 1) : BI.getDate(date.getFullYear(), date.getMonth(), (BI.getLastDateOfMonth(date)).getDate()); |
||||
getBeginDate (date, obj) { |
||||
if (isNotNull(obj.day)) { |
||||
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), date.getMonth(), 1) : getDate(date.getFullYear(), date.getMonth(), (getLastDateOfMonth(date)).getDate()); |
||||
} |
||||
if (BI.isNotNull(obj.week)) { |
||||
return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getWeekStartDate(date) : BI.getWeekEndDate(date); |
||||
if (isNotNull(obj.week)) { |
||||
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getWeekStartDate(date) : getWeekEndDate(date); |
||||
} |
||||
if (BI.isNotNull(obj.month)) { |
||||
return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), date.getMonth(), 1) : BI.getDate(date.getFullYear(), date.getMonth(), (BI.getLastDateOfMonth(date)).getDate()); |
||||
if (isNotNull(obj.month)) { |
||||
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), date.getMonth(), 1) : getDate(date.getFullYear(), date.getMonth(), (getLastDateOfMonth(date)).getDate()); |
||||
} |
||||
if (BI.isNotNull(obj.quarter)) { |
||||
return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getQuarterStartDate(date) : BI.getQuarterEndDate(date); |
||||
if (isNotNull(obj.quarter)) { |
||||
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getQuarterStartDate(date) : getQuarterEndDate(date); |
||||
} |
||||
if (BI.isNotNull(obj.year)) { |
||||
return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), 0, 1) : BI.getDate(date.getFullYear(), 11, 31); |
||||
if (isNotNull(obj.year)) { |
||||
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), 0, 1) : getDate(date.getFullYear(), 11, 31); |
||||
} |
||||
|
||||
return date; |
||||
} |
||||
}); |
||||
})(); |
||||
}, |
||||
}; |
||||
|
@ -1,130 +1,137 @@
|
||||
BI.DynamicDateParamItem = BI.inherit(BI.Widget, { |
||||
import { shortcut, Widget, toPix, isNaturalNumber, i18nText } from "@/core"; |
||||
import { DynamicDateCard } from "./dynamicdate.card"; |
||||
import { SignEditor, TextValueCombo } from "@/case"; |
||||
|
||||
props: function() { |
||||
@shortcut() |
||||
export class DynamicDateParamItem extends Widget { |
||||
static xtype = "bi.dynamic_date_param_item" |
||||
|
||||
static EVENT_CHANGE = "EVENT_CHANGE" |
||||
static EVENT_INPUT_CHANGE = "EVENT_INPUT_CHANGE" |
||||
|
||||
props() { |
||||
return { |
||||
baseCls: "bi-dynamic-date-param-item", |
||||
dateType: BI.DynamicDateCard.TYPE.YEAR, |
||||
validationChecker: function() { |
||||
dateType: DynamicDateCard.TYPE.YEAR, |
||||
validationChecker () { |
||||
return true; |
||||
}, |
||||
value: 0, |
||||
offset: 0, |
||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||
}; |
||||
} |
||||
}, |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
render() { |
||||
const o = this.options; |
||||
|
||||
return { |
||||
type: "bi.htape", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.sign_editor", |
||||
cls: "bi-border bi-focus-shadow bi-border-radius", |
||||
height: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 2), |
||||
validationChecker: function (v) { |
||||
return BI.isNaturalNumber(v); |
||||
height: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 2), |
||||
validationChecker (v) { |
||||
return isNaturalNumber(v); |
||||
}, |
||||
value: o.value, |
||||
ref: function () { |
||||
self.editor = this; |
||||
ref: _ref => { |
||||
this.editor = _ref; |
||||
}, |
||||
errorText: function () { |
||||
return BI.i18nText("BI-Please_Input_Natural_Number"); |
||||
errorText () { |
||||
return i18nText("BI-Please_Input_Natural_Number"); |
||||
}, |
||||
allowBlank: false, |
||||
listeners: [{ |
||||
eventName: BI.SignEditor.EVENT_CONFIRM, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE); |
||||
} |
||||
eventName: SignEditor.EVENT_CONFIRM, |
||||
action: () => { |
||||
this.fireEvent(DynamicDateParamItem.EVENT_CHANGE); |
||||
}, |
||||
}, { |
||||
eventName: BI.SignEditor.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDateParamItem.EVENT_INPUT_CHANGE); |
||||
} |
||||
}] |
||||
eventName: SignEditor.EVENT_CHANGE, |
||||
action: () => { |
||||
this.fireEvent(DynamicDateParamItem.EVENT_INPUT_CHANGE); |
||||
}, |
||||
}], |
||||
}, |
||||
width: 60 |
||||
width: 60, |
||||
}, { |
||||
el: { |
||||
type: "bi.label", |
||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||
text: this._getText() |
||||
text: this._getText(), |
||||
}, |
||||
width: o.dateType === BI.DynamicDateCard.TYPE.WORK_DAY ? 60 : 20 |
||||
width: o.dateType === DynamicDateCard.TYPE.WORK_DAY ? 60 : 20, |
||||
}, { |
||||
type: "bi.text_value_combo", |
||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||
items: [{ |
||||
text: BI.i18nText("BI-Basic_Front"), |
||||
value: 0 |
||||
text: i18nText("BI-Basic_Front"), |
||||
value: 0, |
||||
}, { |
||||
text: BI.i18nText("BI-Basic_Behind"), |
||||
value: 1 |
||||
text: i18nText("BI-Basic_Behind"), |
||||
value: 1, |
||||
}], |
||||
ref: function () { |
||||
self.offsetCombo = this; |
||||
ref: _ref => { |
||||
this.offsetCombo = _ref; |
||||
}, |
||||
container: null, |
||||
value: o.offset, |
||||
listeners: [{ |
||||
eventName: BI.TextValueCombo.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE); |
||||
} |
||||
}] |
||||
}] |
||||
}; |
||||
action: () => { |
||||
this.fireEvent(DynamicDateParamItem.EVENT_CHANGE); |
||||
}, |
||||
}], |
||||
}], |
||||
}; |
||||
} |
||||
|
||||
_getText: function () { |
||||
var text = ""; |
||||
_getText() { |
||||
let text = ""; |
||||
switch (this.options.dateType) { |
||||
case BI.DynamicDateCard.TYPE.YEAR: |
||||
text = BI.i18nText("BI-Basic_Year"); |
||||
case DynamicDateCard.TYPE.YEAR: |
||||
text = i18nText("BI-Basic_Year"); |
||||
break; |
||||
case BI.DynamicDateCard.TYPE.QUARTER: |
||||
text = BI.i18nText("BI-Basic_Single_Quarter"); |
||||
case DynamicDateCard.TYPE.QUARTER: |
||||
text = i18nText("BI-Basic_Single_Quarter"); |
||||
break; |
||||
case BI.DynamicDateCard.TYPE.MONTH: |
||||
text = BI.i18nText("BI-Basic_Month"); |
||||
case DynamicDateCard.TYPE.MONTH: |
||||
text = i18nText("BI-Basic_Month"); |
||||
break; |
||||
case BI.DynamicDateCard.TYPE.WEEK: |
||||
text = BI.i18nText("BI-Basic_Week"); |
||||
case DynamicDateCard.TYPE.WEEK: |
||||
text = i18nText("BI-Basic_Week"); |
||||
break; |
||||
case BI.DynamicDateCard.TYPE.DAY: |
||||
text = BI.i18nText("BI-Basic_Day"); |
||||
case DynamicDateCard.TYPE.DAY: |
||||
text = i18nText("BI-Basic_Day"); |
||||
break; |
||||
case BI.DynamicDateCard.TYPE.WORK_DAY: |
||||
case DynamicDateCard.TYPE.WORK_DAY: |
||||
default: |
||||
text = BI.i18nText("BI-Basic_Work_Day"); |
||||
text = i18nText("BI-Basic_Work_Day"); |
||||
break; |
||||
} |
||||
|
||||
return text; |
||||
}, |
||||
} |
||||
|
||||
checkValidation: function () { |
||||
return BI.isNaturalNumber(this.editor.getValue()); |
||||
}, |
||||
checkValidation() { |
||||
return isNaturalNumber(this.editor.getValue()); |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(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 () { |
||||
getValue() { |
||||
return { |
||||
dateType: this.options.dateType, |
||||
value: this.editor.getValue(), |
||||
offset: this.offsetCombo.getValue()[0] |
||||
offset: this.offsetCombo.getValue()[0], |
||||
}; |
||||
} |
||||
|
||||
}); |
||||
BI.DynamicDateParamItem.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.DynamicDateParamItem.EVENT_INPUT_CHANGE = "EVENT_INPUT_CHANGE"; |
||||
BI.shortcut("bi.dynamic_date_param_item", BI.DynamicDateParamItem); |
||||
} |
||||
|
@ -1,257 +1,267 @@
|
||||
BI.DynamicDatePopup = BI.inherit(BI.Widget, { |
||||
constants: { |
||||
tabHeight: 40, |
||||
}, |
||||
import { shortcut, Widget, createWidget, i18nText, toPix, createItems, isNull, isEmptyObject, isEmptyString, getDate, checkDateVoid, print } from "@/core"; |
||||
import { DynamicDateCombo } from "./dynamicdate.combo"; |
||||
import { TextButton, Tab } from "@/base"; |
||||
import { DateCalendarPopup } from "../date/calendar"; |
||||
import { DynamicDateHelper } from "./dynamicdate.caculate"; |
||||
|
||||
@shortcut() |
||||
export class DynamicDatePopup extends Widget { |
||||
static xtype = "bi.dynamic_date_popup" |
||||
|
||||
props: { |
||||
props = { |
||||
baseCls: "bi-dynamic-date-popup", |
||||
width: 272, |
||||
supportDynamic: true, |
||||
}, |
||||
}; |
||||
|
||||
_init: function () { |
||||
BI.DynamicDatePopup.superclass._init.apply(this, arguments); |
||||
var self = this, opts = this.options, c = this.constants; |
||||
this.storeValue = {type: BI.DynamicDateCombo.Static}; |
||||
BI.createWidget({ |
||||
static EVENT_CHANGE = "EVENT_CHANGE" |
||||
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE" |
||||
static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE" |
||||
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE" |
||||
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW" |
||||
|
||||
_init() { |
||||
super._init(...arguments); |
||||
const opts = this.options; |
||||
this.storeValue = { |
||||
type: DynamicDateCombo.Static, |
||||
}; |
||||
createWidget({ |
||||
element: this, |
||||
type: "bi.vertical", |
||||
items: [{ |
||||
el: this._getTabJson() |
||||
el: this._getTabJson(), |
||||
}, { |
||||
el: { |
||||
type: "bi.grid", |
||||
items: [[{ |
||||
items: [ |
||||
[{ |
||||
type: "bi.text_button", |
||||
cls: "bi-high-light bi-split-top", |
||||
shadow: true, |
||||
text: BI.i18nText("BI-Basic_Clear"), |
||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
text: i18nText("BI-Basic_Clear"), |
||||
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
listeners: [{ |
||||
eventName: BI.TextButton.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE); |
||||
} |
||||
}] |
||||
eventName: TextButton.EVENT_CHANGE, |
||||
action: () => { |
||||
this.fireEvent(DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE); |
||||
}, |
||||
}], |
||||
}, { |
||||
type: "bi.text_button", |
||||
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", |
||||
shadow: true, |
||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
text: BI.i18nText("BI-Multi_Date_Today"), |
||||
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
text: i18nText("BI-Multi_Date_Today"), |
||||
disabled: this._checkTodayValid(), |
||||
ref: function () { |
||||
self.todayButton = this; |
||||
ref: _ref => { |
||||
this.todayButton = _ref; |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.TextButton.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE); |
||||
} |
||||
}] |
||||
eventName: TextButton.EVENT_CHANGE, |
||||
action: () => { |
||||
this.fireEvent(DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE); |
||||
}, |
||||
}], |
||||
}, { |
||||
type: "bi.text_button", |
||||
cls: "bi-high-light bi-split-top", |
||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
shadow: true, |
||||
text: BI.i18nText("BI-Basic_OK"), |
||||
text: i18nText("BI-Basic_OK"), |
||||
listeners: [{ |
||||
eventName: BI.TextButton.EVENT_CHANGE, |
||||
action: function () { |
||||
var type = self.dateTab.getSelect(); |
||||
if (type === BI.DynamicDateCombo.Dynamic) { |
||||
self.dynamicPane.checkValidation(true) && self.fireEvent(BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); |
||||
eventName: TextButton.EVENT_CHANGE, |
||||
action: () => { |
||||
const type = this.dateTab.getSelect(); |
||||
if (type === DynamicDateCombo.Dynamic) { |
||||
this.dynamicPane.checkValidation(true) && this.fireEvent(DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); |
||||
} else { |
||||
self.fireEvent(BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); |
||||
this.fireEvent(DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); |
||||
} |
||||
} |
||||
}] |
||||
}]], |
||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT |
||||
}, |
||||
}], |
||||
}] |
||||
], |
||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||
}, |
||||
}], |
||||
}); |
||||
this.setValue(opts.value); |
||||
}, |
||||
} |
||||
|
||||
_getTabJson() { |
||||
const o = this.options; |
||||
|
||||
_getTabJson: function () { |
||||
var self = this, o = this.options; |
||||
return { |
||||
type: "bi.tab", |
||||
logic: { |
||||
dynamic: true |
||||
dynamic: true, |
||||
}, |
||||
ref: function () { |
||||
self.dateTab = this; |
||||
ref: _ref => { |
||||
this.dateTab = _ref; |
||||
}, |
||||
tab: { |
||||
type: "bi.linear_segment", |
||||
invisible: !o.supportDynamic, |
||||
cls: "bi-split-bottom", |
||||
height: this.constants.tabHeight, |
||||
items: BI.createItems([{ |
||||
text: BI.i18nText("BI-Multi_Date_YMD"), |
||||
value: BI.DynamicDateCombo.Static |
||||
items: createItems([{ |
||||
text: i18nText("BI-Multi_Date_YMD"), |
||||
value: DynamicDateCombo.Static, |
||||
}, { |
||||
text: BI.i18nText("BI-Basic_Dynamic_Title"), |
||||
value: BI.DynamicDateCombo.Dynamic |
||||
text: i18nText("BI-Basic_Dynamic_Title"), |
||||
value: DynamicDateCombo.Dynamic, |
||||
}], { |
||||
textAlign: "center" |
||||
}) |
||||
textAlign: "center", |
||||
}), |
||||
}, |
||||
cardCreator: function (v) { |
||||
cardCreator: v => { |
||||
switch (v) { |
||||
case BI.DynamicDateCombo.Dynamic: |
||||
case DynamicDateCombo.Dynamic: |
||||
return { |
||||
type: "bi.dynamic_date_card", |
||||
cls: "dynamic-date-pane", |
||||
listeners: [{ |
||||
eventName: "EVENT_CHANGE", |
||||
action: function () { |
||||
self._setInnerValue(self.year, v); |
||||
} |
||||
action: () => { |
||||
this._setInnerValue(this.year, v); |
||||
}, |
||||
}], |
||||
min: self.options.min, |
||||
max: self.options.max, |
||||
ref: function () { |
||||
self.dynamicPane = this; |
||||
} |
||||
min: this.options.min, |
||||
max: this.options.max, |
||||
ref: _ref => { |
||||
this.dynamicPane = _ref; |
||||
}, |
||||
}; |
||||
case BI.DynamicDateCombo.Static: |
||||
case DynamicDateCombo.Static: |
||||
default: |
||||
return { |
||||
type: "bi.date_calendar_popup", |
||||
behaviors: o.behaviors, |
||||
min: self.options.min, |
||||
max: self.options.max, |
||||
min: this.options.min, |
||||
max: this.options.max, |
||||
listeners: [{ |
||||
eventName: BI.DateCalendarPopup.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDatePopup.EVENT_CHANGE); |
||||
} |
||||
eventName: DateCalendarPopup.EVENT_CHANGE, |
||||
action: () => { |
||||
this.fireEvent(DynamicDatePopup.EVENT_CHANGE); |
||||
}, |
||||
}, { |
||||
eventName: BI.DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
||||
} |
||||
eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, |
||||
action: () => { |
||||
this.fireEvent(DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
||||
}, |
||||
}], |
||||
ref: function () { |
||||
self.ymd = this; |
||||
} |
||||
ref: _ref => { |
||||
this.ymd = _ref; |
||||
}, |
||||
}; |
||||
} |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.Tab.EVENT_CHANGE, |
||||
action: function () { |
||||
var v = self.dateTab.getSelect(); |
||||
eventName: Tab.EVENT_CHANGE, |
||||
action: () => { |
||||
const v = this.dateTab.getSelect(); |
||||
let date; |
||||
switch (v) { |
||||
case BI.DynamicDateCombo.Static: |
||||
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); |
||||
self.ymd.setValue({ |
||||
case DynamicDateCombo.Static: |
||||
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); |
||||
this.ymd.setValue({ |
||||
year: date.getFullYear(), |
||||
month: date.getMonth() + 1, |
||||
day: date.getDate() |
||||
day: date.getDate(), |
||||
}); |
||||
self._setInnerValue(); |
||||
this._setInnerValue(); |
||||
break; |
||||
case BI.DynamicDateCombo.Dynamic: |
||||
case DynamicDateCombo.Dynamic: |
||||
default: |
||||
if(self.storeValue && self.storeValue.type === BI.DynamicDateCombo.Dynamic) { |
||||
self.dynamicPane.setValue(self.storeValue.value); |
||||
if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) { |
||||
this.dynamicPane.setValue(this.storeValue.value); |
||||
} else { |
||||
self.dynamicPane.setValue({ |
||||
year: 0 |
||||
this.dynamicPane.setValue({ |
||||
year: 0, |
||||
}); |
||||
} |
||||
self._setInnerValue(); |
||||
this._setInnerValue(); |
||||
break; |
||||
} |
||||
} |
||||
}] |
||||
}; |
||||
}, |
||||
}], |
||||
}; |
||||
} |
||||
|
||||
_setInnerValue: function () { |
||||
if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { |
||||
this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); |
||||
_setInnerValue() { |
||||
if (this.dateTab.getSelect() === DynamicDateCombo.Static) { |
||||
this.todayButton.setValue(i18nText("BI-Multi_Date_Today")); |
||||
this.todayButton.setEnable(!this._checkTodayValid()); |
||||
} else { |
||||
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue()); |
||||
date = BI.print(date, "%Y-%X-%d"); |
||||
let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue()); |
||||
date = print(date, "%Y-%X-%d"); |
||||
this.todayButton.setValue(date); |
||||
this.todayButton.setEnable(false); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
_checkValueValid: function (value) { |
||||
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); |
||||
}, |
||||
_checkValueValid(value) { |
||||
return isNull(value) || isEmptyObject(value) || isEmptyString(value); |
||||
} |
||||
|
||||
_checkTodayValid: function () { |
||||
var o = this.options; |
||||
var today = BI.getDate(); |
||||
return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; |
||||
}, |
||||
_checkTodayValid() { |
||||
const o = this.options; |
||||
const today = getDate(); |
||||
|
||||
setMinDate: function (minDate) { |
||||
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; |
||||
} |
||||
|
||||
setMinDate(minDate) { |
||||
if (this.options.min !== minDate) { |
||||
this.options.min = minDate; |
||||
this.ymd && this.ymd.setMinDate(minDate); |
||||
this.dynamicPane && this.dynamicPane.setMinDate(minDate); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setMaxDate: function (maxDate) { |
||||
setMaxDate(maxDate) { |
||||
if (this.options.max !== maxDate) { |
||||
this.options.max = maxDate; |
||||
this.ymd && this.ymd.setMaxDate(maxDate); |
||||
this.dynamicPane && this.dynamicPane.setMaxDate(maxDate); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.storeValue = v; |
||||
var self = this; |
||||
var type, value; |
||||
v = v || {}; |
||||
type = v.type || BI.DynamicDateCombo.Static; |
||||
value = v.value || v; |
||||
const type = v.type || DynamicDateCombo.Static; |
||||
const value = v.value || v; |
||||
this.dateTab.setSelect(type); |
||||
switch (type) { |
||||
case BI.DynamicDateCombo.Dynamic: |
||||
case DynamicDateCombo.Dynamic: |
||||
this.dynamicPane.setValue(value); |
||||
self._setInnerValue(); |
||||
this._setInnerValue(); |
||||
break; |
||||
case BI.DynamicDateCombo.Static: |
||||
case DynamicDateCombo.Static: |
||||
default: |
||||
if (this._checkValueValid(value)) { |
||||
var date = BI.getDate(); |
||||
const date = getDate(); |
||||
this.ymd.setValue({ |
||||
year: date.getFullYear(), |
||||
month: date.getMonth() + 1, |
||||
day: date.getDate() |
||||
day: date.getDate(), |
||||
}); |
||||
this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); |
||||
this.todayButton.setValue(i18nText("BI-Multi_Date_Today")); |
||||
} else { |
||||
this.ymd.setValue(value); |
||||
this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); |
||||
this.todayButton.setValue(i18nText("BI-Multi_Date_Today")); |
||||
} |
||||
this.todayButton.setEnable(!this._checkTodayValid()); |
||||
break; |
||||
} |
||||
}, |
||||
} |
||||
|
||||
getValue: function () { |
||||
getValue() { |
||||
return { |
||||
type: this.dateTab.getSelect(), |
||||
value: this.dateTab.getValue() |
||||
value: this.dateTab.getValue(), |
||||
}; |
||||
} |
||||
}); |
||||
BI.DynamicDatePopup.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; |
||||
BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; |
||||
BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; |
||||
BI.DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"; |
||||
BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup); |
||||
} |
||||
|
@ -0,0 +1,6 @@
|
||||
export { DynamicDateHelper } from "./dynamicdate.caculate"; |
||||
export { DynamicDateCard } from "./dynamicdate.card"; |
||||
export { DynamicDateCombo } from "./dynamicdate.combo"; |
||||
export { DynamicDateParamItem } from "./dynamicdate.param.item"; |
||||
export { DynamicDatePopup } from "./dynamicdate.popup"; |
||||
export { DynamicDateTrigger } from "./dynamicdate.trigger"; |
@ -1,271 +1,280 @@
|
||||
BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { |
||||
constants: { |
||||
tabHeight: 40, |
||||
buttonHeight: 24 |
||||
}, |
||||
import { shortcut, Widget, createWidget, toPix, i18nText, createItems, print, isNull, isEmptyObject, isEmptyString, getDate, checkDateVoid, extend } from "@/core"; |
||||
import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate"; |
||||
import { TextButton, Tab } from "@/base"; |
||||
import { DateCalendarPopup } from "../date/calendar"; |
||||
import { DynamicDateTimeCombo } from "./dynamicdatetime.combo"; |
||||
|
||||
@shortcut() |
||||
export class DynamicDateTimePopup extends Widget { |
||||
static xtype = "bi.dynamic_date_time_popup" |
||||
|
||||
props: { |
||||
props = { |
||||
baseCls: "bi-dynamic-date-time-popup", |
||||
width: 272, |
||||
supportDynamic: true, |
||||
}, |
||||
}; |
||||
|
||||
_init: function () { |
||||
BI.DynamicDateTimePopup.superclass._init.apply(this, arguments); |
||||
var self = this, opts = this.options, c = this.constants; |
||||
this.storeValue = {type: BI.DynamicDateCombo.Static}; |
||||
BI.createWidget({ |
||||
static EVENT_CHANGE = "EVENT_CHANGE" |
||||
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE" |
||||
static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE" |
||||
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE" |
||||
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW" |
||||
|
||||
_init() { |
||||
super._init(...arguments); |
||||
const opts = this.options; |
||||
this.storeValue = { |
||||
type: DynamicDateCombo.Static, |
||||
}; |
||||
createWidget({ |
||||
element: this, |
||||
type: "bi.vertical", |
||||
items: [{ |
||||
el: this._getTabJson() |
||||
el: this._getTabJson(), |
||||
}, { |
||||
el: { |
||||
type: "bi.grid", |
||||
items: [[{ |
||||
items: [ |
||||
[{ |
||||
type: "bi.text_button", |
||||
cls: "bi-high-light bi-split-top", |
||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
shadow: true, |
||||
text: BI.i18nText("BI-Basic_Clear"), |
||||
text: i18nText("BI-Basic_Clear"), |
||||
listeners: [{ |
||||
eventName: BI.TextButton.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE); |
||||
} |
||||
}] |
||||
eventName: TextButton.EVENT_CHANGE, |
||||
action: () => { |
||||
this.fireEvent(DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE); |
||||
}, |
||||
}], |
||||
}, { |
||||
type: "bi.text_button", |
||||
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", |
||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
shadow: true, |
||||
text: BI.i18nText("BI-Multi_Date_Today"), |
||||
text: i18nText("BI-Multi_Date_Today"), |
||||
disabled: this._checkTodayValid(), |
||||
ref: function () { |
||||
self.todayButton = this; |
||||
ref: _ref => { |
||||
this.todayButton = _ref; |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.TextButton.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE); |
||||
} |
||||
}] |
||||
eventName: TextButton.EVENT_CHANGE, |
||||
action: () => { |
||||
this.fireEvent(DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE); |
||||
}, |
||||
}], |
||||
}, { |
||||
type: "bi.text_button", |
||||
cls: "bi-high-light bi-split-top", |
||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
||||
shadow: true, |
||||
text: BI.i18nText("BI-Basic_OK"), |
||||
text: i18nText("BI-Basic_OK"), |
||||
listeners: [{ |
||||
eventName: BI.TextButton.EVENT_CHANGE, |
||||
action: function () { |
||||
var type = self.dateTab.getSelect(); |
||||
if (type === BI.DynamicDateCombo.Dynamic) { |
||||
self.dynamicPane.checkValidation(true) && self.fireEvent(BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE); |
||||
eventName: TextButton.EVENT_CHANGE, |
||||
action: () => { |
||||
const type = this.dateTab.getSelect(); |
||||
if (type === DynamicDateCombo.Dynamic) { |
||||
this.dynamicPane.checkValidation(true) && this.fireEvent(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE); |
||||
} else { |
||||
self.fireEvent(BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE) |
||||
} |
||||
} |
||||
}] |
||||
}]], |
||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT |
||||
this.fireEvent(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE); |
||||
} |
||||
}, |
||||
}], |
||||
}] |
||||
], |
||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||
}, |
||||
}], |
||||
}); |
||||
this.setValue(opts.value); |
||||
}, |
||||
} |
||||
|
||||
_getTabJson() { |
||||
const o = this.options; |
||||
|
||||
_getTabJson: function () { |
||||
var self = this, o = this.options; |
||||
return { |
||||
type: "bi.tab", |
||||
logic: { |
||||
dynamic: true |
||||
dynamic: true, |
||||
}, |
||||
ref: function () { |
||||
self.dateTab = this; |
||||
ref: _ref => { |
||||
this.dateTab = _ref; |
||||
}, |
||||
tab: { |
||||
type: "bi.linear_segment", |
||||
invisible: !o.supportDynamic, |
||||
cls: "bi-split-bottom", |
||||
height: this.constants.tabHeight, |
||||
items: BI.createItems([{ |
||||
text: BI.i18nText("BI-Multi_Date_YMD"), |
||||
value: BI.DynamicDateCombo.Static |
||||
items: createItems([{ |
||||
text: i18nText("BI-Multi_Date_YMD"), |
||||
value: DynamicDateCombo.Static, |
||||
}, { |
||||
text: BI.i18nText("BI-Basic_Dynamic_Title"), |
||||
value: BI.DynamicDateCombo.Dynamic |
||||
text: i18nText("BI-Basic_Dynamic_Title"), |
||||
value: DynamicDateCombo.Dynamic, |
||||
}], { |
||||
textAlign: "center" |
||||
}) |
||||
textAlign: "center", |
||||
}), |
||||
}, |
||||
cardCreator: function (v) { |
||||
cardCreator: v => { |
||||
switch (v) { |
||||
case BI.DynamicDateCombo.Dynamic: |
||||
case DynamicDateCombo.Dynamic: |
||||
return { |
||||
type: "bi.dynamic_date_card", |
||||
cls: "dynamic-date-pane", |
||||
listeners: [{ |
||||
eventName: "EVENT_CHANGE", |
||||
action: function () { |
||||
self._setInnerValue(self.year, v); |
||||
} |
||||
action: () => { |
||||
this._setInnerValue(this.year, v); |
||||
}, |
||||
}], |
||||
ref: function () { |
||||
self.dynamicPane = this; |
||||
ref: _ref => { |
||||
this.dynamicPane = _ref; |
||||
}, |
||||
min: self.options.min, |
||||
max: self.options.max, |
||||
min: this.options.min, |
||||
max: this.options.max, |
||||
}; |
||||
case BI.DynamicDateCombo.Static: |
||||
case DynamicDateCombo.Static: |
||||
default: |
||||
return { |
||||
type: "bi.vertical", |
||||
items: [{ |
||||
type: "bi.date_calendar_popup", |
||||
behaviors: o.behaviors, |
||||
min: self.options.min, |
||||
max: self.options.max, |
||||
ref: function () { |
||||
self.ymd = this; |
||||
min: this.options.min, |
||||
max: this.options.max, |
||||
ref: _ref => { |
||||
this.ymd = _ref; |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, |
||||
action: function () { |
||||
self.fireEvent(BI.DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
||||
} |
||||
eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, |
||||
action: () => { |
||||
this.fireEvent(DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW); |
||||
}, |
||||
}], |
||||
}, { |
||||
el: { |
||||
type: "bi.dynamic_date_time_select", |
||||
cls: "bi-split-top", |
||||
ref: function () { |
||||
self.timeSelect = this; |
||||
ref: _ref => { |
||||
this.timeSelect = _ref; |
||||
}, |
||||
height: 40 |
||||
} |
||||
}] |
||||
height: 40, |
||||
}, |
||||
}], |
||||
}; |
||||
} |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.Tab.EVENT_CHANGE, |
||||
action: function () { |
||||
var v = self.dateTab.getSelect(); |
||||
eventName: Tab.EVENT_CHANGE, |
||||
action: () => { |
||||
const v = this.dateTab.getSelect(); |
||||
const date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); |
||||
switch (v) { |
||||
case BI.DynamicDateCombo.Static: |
||||
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); |
||||
self.ymd.setValue({ |
||||
case DynamicDateCombo.Static: |
||||
this.ymd.setValue({ |
||||
year: date.getFullYear(), |
||||
month: date.getMonth() + 1, |
||||
day: date.getDate() |
||||
day: date.getDate(), |
||||
}); |
||||
self.timeSelect.setValue(); |
||||
self._setInnerValue(); |
||||
this.timeSelect.setValue(); |
||||
this._setInnerValue(); |
||||
break; |
||||
case BI.DynamicDateCombo.Dynamic: |
||||
case DynamicDateCombo.Dynamic: |
||||
default: |
||||
if(self.storeValue && self.storeValue.type === BI.DynamicDateCombo.Dynamic) { |
||||
self.dynamicPane.setValue(self.storeValue.value); |
||||
if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) { |
||||
this.dynamicPane.setValue(this.storeValue.value); |
||||
} else { |
||||
self.dynamicPane.setValue({ |
||||
year: 0 |
||||
this.dynamicPane.setValue({ |
||||
year: 0, |
||||
}); |
||||
} |
||||
self._setInnerValue(); |
||||
this._setInnerValue(); |
||||
break; |
||||
} |
||||
} |
||||
}] |
||||
}; |
||||
}, |
||||
}], |
||||
}; |
||||
} |
||||
|
||||
_setInnerValue: function () { |
||||
if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { |
||||
this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); |
||||
_setInnerValue() { |
||||
if (this.dateTab.getSelect() === DynamicDateCombo.Static) { |
||||
this.todayButton.setValue(i18nText("BI-Multi_Date_Today")); |
||||
this.todayButton.setEnable(!this._checkTodayValid()); |
||||
} else { |
||||
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue()); |
||||
date = BI.print(date, "%Y-%X-%d"); |
||||
let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue()); |
||||
date = print(date, "%Y-%X-%d"); |
||||
this.todayButton.setValue(date); |
||||
this.todayButton.setEnable(false); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
_checkValueValid: function (value) { |
||||
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); |
||||
}, |
||||
_checkValueValid(value) { |
||||
return isNull(value) || isEmptyObject(value) || isEmptyString(value); |
||||
} |
||||
|
||||
_checkTodayValid: function () { |
||||
var o = this.options; |
||||
var today = BI.getDate(); |
||||
return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; |
||||
}, |
||||
_checkTodayValid() { |
||||
const o = this.options; |
||||
const today = getDate(); |
||||
|
||||
setMinDate: function (minDate) { |
||||
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; |
||||
} |
||||
|
||||
setMinDate(minDate) { |
||||
if (this.options.min !== minDate) { |
||||
this.options.min = minDate; |
||||
this.ymd.setMinDate(minDate); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setMaxDate: function (maxDate) { |
||||
setMaxDate(maxDate) { |
||||
if (this.options.max !== maxDate) { |
||||
this.options.max = maxDate; |
||||
this.ymd.setMaxDate(maxDate); |
||||
} |
||||
}, |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
setValue(v) { |
||||
this.storeValue = v; |
||||
var self = this; |
||||
var type, value; |
||||
v = v || {}; |
||||
type = v.type || BI.DynamicDateCombo.Static; |
||||
value = v.value || v; |
||||
const type = v.type || DynamicDateCombo.Static; |
||||
const value = v.value || v; |
||||
this.dateTab.setSelect(type); |
||||
switch (type) { |
||||
case BI.DynamicDateCombo.Dynamic: |
||||
case DynamicDateCombo.Dynamic: |
||||
this.dynamicPane.setValue(value); |
||||
self._setInnerValue(); |
||||
this._setInnerValue(); |
||||
break; |
||||
case BI.DynamicDateCombo.Static: |
||||
case DynamicDateCombo.Static: |
||||
default: |
||||
if (this._checkValueValid(value)) { |
||||
var date = BI.getDate(); |
||||
const date = getDate(); |
||||
this.ymd.setValue({ |
||||
year: date.getFullYear(), |
||||
month: date.getMonth() + 1, |
||||
day: date.getDate() |
||||
day: date.getDate(), |
||||
}); |
||||
this.timeSelect.setValue(); |
||||
this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); |
||||
this.todayButton.setValue(i18nText("BI-Multi_Date_Today")); |
||||
} else { |
||||
this.ymd.setValue(value); |
||||
this.timeSelect.setValue({ |
||||
hour: value.hour, |
||||
minute: value.minute, |
||||
second: value.second |
||||
second: value.second, |
||||
}); |
||||
this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); |
||||
this.todayButton.setValue(i18nText("BI-Multi_Date_Today")); |
||||
} |
||||
this.todayButton.setEnable(!this._checkTodayValid()); |
||||
break; |
||||
} |
||||
}, |
||||
} |
||||
|
||||
getValue() { |
||||
const type = this.dateTab.getSelect(); |
||||
|
||||
getValue: function () { |
||||
var type = this.dateTab.getSelect(); |
||||
return { |
||||
type: type, |
||||
value: type === BI.DynamicDateTimeCombo.Static ? BI.extend(this.ymd.getValue(), this.timeSelect.getValue()) : this.dynamicPane.getValue() |
||||
type, |
||||
value: type === DynamicDateTimeCombo.Static ? extend(this.ymd.getValue(), this.timeSelect.getValue()) : this.dynamicPane.getValue(), |
||||
}; |
||||
} |
||||
}); |
||||
BI.DynamicDateTimePopup.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; |
||||
BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; |
||||
BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; |
||||
BI.DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"; |
||||
BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup); |
||||
} |
||||
|
@ -0,0 +1,4 @@
|
||||
export { DynamicDateTimeSelect } from "./dynamicdatetime.timeselect"; |
||||
export { DynamicDateTimeCombo } from "./dynamicdatetime.combo"; |
||||
export { DynamicDateTimePopup } from "./dynamicdatetime.popup"; |
||||
export { DynamicDateTimeTrigger } from "./dynamicdatetime.trigger"; |
@ -1,12 +1,27 @@
|
||||
import { Collapse } from "./collapse/collapse"; |
||||
import * as calendar from "./date/calendar"; |
||||
import * as dynamicdate from "./dynamicdate"; |
||||
import * as datepane from "./datepane"; |
||||
import * as datetime from "./datetime"; |
||||
import * as datetimepane from "./datetimepane"; |
||||
import * as dynamicdatetime from "./dynamicdatetime"; |
||||
|
||||
Object.assign(BI, { |
||||
Collapse, |
||||
...calendar, |
||||
...dynamicdate, |
||||
...datepane, |
||||
...datetime, |
||||
...datetimepane, |
||||
...dynamicdatetime, |
||||
}); |
||||
|
||||
export * from "./date/calendar"; |
||||
export * from "./dynamicdate"; |
||||
export * from "./datepane"; |
||||
export * from "./datetime"; |
||||
export * from "./datetimepane"; |
||||
export * from "./dynamicdatetime"; |
||||
export { |
||||
Collapse |
||||
}; |
||||
|
Loading…
Reference in new issue