|
|
|
@ -1,6 +1,27 @@
|
|
|
|
|
import { shortcut, Widget, i18nText, createItems, each, isNotNull, map, has, bind, last, extend, checkDateVoid, isNull, isNotEmptyString, parseDateTime, any } from "@/core"; |
|
|
|
|
import { ButtonGroup, Bubbles } from "@/base"; |
|
|
|
|
import { MultiSelectItem } from "@/case"; |
|
|
|
|
import { |
|
|
|
|
VerticalLayout, |
|
|
|
|
FloatLeftLayout, |
|
|
|
|
VerticalAdaptLayout, |
|
|
|
|
shortcut, |
|
|
|
|
Widget, |
|
|
|
|
i18nText, |
|
|
|
|
createItems, |
|
|
|
|
each, |
|
|
|
|
isNotNull, |
|
|
|
|
map, |
|
|
|
|
has, |
|
|
|
|
bind, |
|
|
|
|
last, |
|
|
|
|
extend, |
|
|
|
|
checkDateVoid, |
|
|
|
|
isNull, |
|
|
|
|
isNotEmptyString, |
|
|
|
|
parseDateTime, |
|
|
|
|
any |
|
|
|
|
} from "@/core"; |
|
|
|
|
import { Label, ButtonGroup, Bubbles } from "@/base"; |
|
|
|
|
import { MultiSelectItem, TextValueCombo } from "@/case"; |
|
|
|
|
import { DynamicDateParamItem } from "./dynamicdate.param.item"; |
|
|
|
|
import { DynamicDateHelper } from "./dynamicdate.caculate"; |
|
|
|
|
|
|
|
|
|
@shortcut() |
|
|
|
@ -29,51 +50,65 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
this.position = DynamicDateCard.OFFSET.CURRENT; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
type: "bi.vertical", |
|
|
|
|
items: [{ |
|
|
|
|
type: VerticalLayout.xtype, |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.label", |
|
|
|
|
type: Label.xtype, |
|
|
|
|
text: i18nText("BI-Multi_Date_Relative_Current_Time"), |
|
|
|
|
textAlign: "left", |
|
|
|
|
lgap: 10, |
|
|
|
|
}, |
|
|
|
|
tgap: 10, |
|
|
|
|
bgap: 5, |
|
|
|
|
}, { |
|
|
|
|
type: "bi.button_group", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
type: ButtonGroup.xtype, |
|
|
|
|
ref: _ref => { |
|
|
|
|
this.checkgroup = _ref; |
|
|
|
|
}, |
|
|
|
|
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI, |
|
|
|
|
lgap: 4, |
|
|
|
|
value: [DynamicDateCard.TYPE.YEAR], |
|
|
|
|
items: createItems([{ |
|
|
|
|
items: createItems( |
|
|
|
|
[ |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Year"), |
|
|
|
|
value: DynamicDateCard.TYPE.YEAR, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Single_Quarter"), |
|
|
|
|
value: DynamicDateCard.TYPE.QUARTER, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Month"), |
|
|
|
|
value: DynamicDateCard.TYPE.MONTH, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Week"), |
|
|
|
|
value: DynamicDateCard.TYPE.WEEK, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Day"), |
|
|
|
|
value: DynamicDateCard.TYPE.DAY, |
|
|
|
|
}], { |
|
|
|
|
type: "bi.multi_select_item", |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
{ |
|
|
|
|
type: MultiSelectItem.xtype, |
|
|
|
|
logic: { |
|
|
|
|
dynamic: true, |
|
|
|
|
}, |
|
|
|
|
iconWrapperWidth: 26, |
|
|
|
|
}), |
|
|
|
|
layouts: [{ |
|
|
|
|
type: "bi.left", |
|
|
|
|
} |
|
|
|
|
), |
|
|
|
|
layouts: [ |
|
|
|
|
{ |
|
|
|
|
type: FloatLeftLayout.xtype, |
|
|
|
|
rgap: 4, |
|
|
|
|
}], |
|
|
|
|
listeners: [{ |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
listeners: [ |
|
|
|
|
{ |
|
|
|
|
eventName: ButtonGroup.EVENT_CHANGE, |
|
|
|
|
action: () => { |
|
|
|
|
const value = this.checkgroup.getValue(); |
|
|
|
@ -91,7 +126,9 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.resultPane.populate(this._getParamJson(map(this.checkgroup.getValue(), (idx, v) => { |
|
|
|
|
this.resultPane.populate( |
|
|
|
|
this._getParamJson( |
|
|
|
|
map(this.checkgroup.getValue(), (idx, v) => { |
|
|
|
|
const obj = { |
|
|
|
|
dateType: v, |
|
|
|
|
}; |
|
|
|
@ -101,17 +138,22 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return obj; |
|
|
|
|
}))); |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
this.position = DynamicDateCard.OFFSET.CURRENT; |
|
|
|
|
this.fireEvent("EVENT_CHANGE"); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
}, { |
|
|
|
|
type: "bi.vertical_adapt", |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
type: VerticalAdaptLayout.xtype, |
|
|
|
|
lgap: 2, |
|
|
|
|
items: [{ |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.multi_select_item", |
|
|
|
|
type: MultiSelectItem.xtype, |
|
|
|
|
iconWrapperWidth: 26, |
|
|
|
|
ref: _ref => { |
|
|
|
|
this.workDayBox = _ref; |
|
|
|
@ -121,38 +163,53 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
}, |
|
|
|
|
text: i18nText("BI-Basic_Work_Day"), |
|
|
|
|
value: DynamicDateCard.TYPE.WORK_DAY, |
|
|
|
|
listeners: [{ |
|
|
|
|
listeners: [ |
|
|
|
|
{ |
|
|
|
|
eventName: MultiSelectItem.EVENT_CHANGE, |
|
|
|
|
action: () => { |
|
|
|
|
if (this.workDayBox.isSelected()) { |
|
|
|
|
this.checkgroup.setValue(); |
|
|
|
|
} |
|
|
|
|
this.resultPane.populate(this.workDayBox.isSelected() ? this._getParamJson([{ |
|
|
|
|
this.resultPane.populate( |
|
|
|
|
this.workDayBox.isSelected() |
|
|
|
|
? this._getParamJson([ |
|
|
|
|
{ |
|
|
|
|
dateType: DynamicDateCard.TYPE.WORK_DAY, |
|
|
|
|
}]) : []); |
|
|
|
|
} |
|
|
|
|
]) |
|
|
|
|
: [] |
|
|
|
|
); |
|
|
|
|
this.position = DynamicDateCard.OFFSET.CURRENT; |
|
|
|
|
this.fireEvent("EVENT_CHANGE"); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
ref: _ref => { |
|
|
|
|
this.workDay = _ref; |
|
|
|
|
}, |
|
|
|
|
}, { |
|
|
|
|
type: "bi.button_group", |
|
|
|
|
items: this._getParamJson([{ |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
type: ButtonGroup.xtype, |
|
|
|
|
items: this._getParamJson([ |
|
|
|
|
{ |
|
|
|
|
dateType: DynamicDateCard.TYPE.YEAR, |
|
|
|
|
}]), |
|
|
|
|
} |
|
|
|
|
]), |
|
|
|
|
ref: _ref => { |
|
|
|
|
this.resultPane = _ref; |
|
|
|
|
}, |
|
|
|
|
layouts: [{ |
|
|
|
|
type: "bi.vertical", |
|
|
|
|
layouts: [ |
|
|
|
|
{ |
|
|
|
|
type: VerticalLayout.xtype, |
|
|
|
|
bgap: 10, |
|
|
|
|
hgap: 10, |
|
|
|
|
}], |
|
|
|
|
}], |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -160,22 +217,25 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
const items = map(values, (idx, value) => { |
|
|
|
|
return { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.dynamic_date_param_item", |
|
|
|
|
type: DynamicDateParamItem.xtype, |
|
|
|
|
validationChecker: bind(this._checkDate, this), |
|
|
|
|
dateType: value.dateType, |
|
|
|
|
value: value.value, |
|
|
|
|
offset: value.offset, |
|
|
|
|
listeners: [{ |
|
|
|
|
listeners: [ |
|
|
|
|
{ |
|
|
|
|
eventName: "EVENT_CHANGE", |
|
|
|
|
action: () => { |
|
|
|
|
this.fireEvent("EVENT_CHANGE"); |
|
|
|
|
}, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
eventName: "EVENT_INPUT_CHANGE", |
|
|
|
|
action() { |
|
|
|
|
Bubbles.hide("dynamic-date-error"); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
tgap: idx === 0 ? 5 : 0, |
|
|
|
|
}; |
|
|
|
@ -185,7 +245,7 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
const comboItems = this._getText(DynamicDateCard.TYPE.MONTH); |
|
|
|
|
comboItems[0].text = i18nText("BI-Basic_Empty"); |
|
|
|
|
items.push({ |
|
|
|
|
type: "bi.text_value_combo", |
|
|
|
|
type: TextValueCombo.xtype, |
|
|
|
|
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
|
|
|
|
items: comboItems, |
|
|
|
|
container: null, |
|
|
|
@ -193,19 +253,25 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
ref: _ref => { |
|
|
|
|
this.textValueCombo = _ref; |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
listeners: [ |
|
|
|
|
{ |
|
|
|
|
eventName: "EVENT_CHANGE", |
|
|
|
|
action: () => { |
|
|
|
|
this.position = this.textValueCombo.getValue()[0]; |
|
|
|
|
this.textValueCombo.setValue(this.position); |
|
|
|
|
this.fireEvent("EVENT_CHANGE"); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
if (values.length !== 0 && last(values).dateType !== DynamicDateCard.TYPE.DAY && last(values).dateType !== DynamicDateCard.TYPE.WORK_DAY) { |
|
|
|
|
if ( |
|
|
|
|
values.length !== 0 && |
|
|
|
|
last(values).dateType !== DynamicDateCard.TYPE.DAY && |
|
|
|
|
last(values).dateType !== DynamicDateCard.TYPE.WORK_DAY |
|
|
|
|
) { |
|
|
|
|
items.push({ |
|
|
|
|
type: "bi.text_value_combo", |
|
|
|
|
type: TextValueCombo.xtype, |
|
|
|
|
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
|
|
|
|
container: null, |
|
|
|
|
items: this._getText(last(values).dateType), |
|
|
|
@ -213,14 +279,16 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
ref: _ref => { |
|
|
|
|
this.textValueCombo = _ref; |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
listeners: [ |
|
|
|
|
{ |
|
|
|
|
eventName: "EVENT_CHANGE", |
|
|
|
|
action: () => { |
|
|
|
|
this.position = this.textValueCombo.getValue()[0]; |
|
|
|
|
this.textValueCombo.setValue(this.position); |
|
|
|
|
this.fireEvent("EVENT_CHANGE"); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -238,50 +306,66 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
_getText(lastValue) { |
|
|
|
|
switch (lastValue) { |
|
|
|
|
case DynamicDateCard.TYPE.YEAR: |
|
|
|
|
return [{ |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Current_Day"), |
|
|
|
|
value: DynamicDateCard.OFFSET.CURRENT, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Year_Begin"), |
|
|
|
|
value: DynamicDateCard.OFFSET.BEGIN, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Year_End"), |
|
|
|
|
value: DynamicDateCard.OFFSET.END, |
|
|
|
|
}]; |
|
|
|
|
} |
|
|
|
|
]; |
|
|
|
|
case DynamicDateCard.TYPE.QUARTER: |
|
|
|
|
return [{ |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Current_Day"), |
|
|
|
|
value: DynamicDateCard.OFFSET.CURRENT, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Quarter_Begin"), |
|
|
|
|
value: DynamicDateCard.OFFSET.BEGIN, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Quarter_End"), |
|
|
|
|
value: DynamicDateCard.OFFSET.END, |
|
|
|
|
}]; |
|
|
|
|
} |
|
|
|
|
]; |
|
|
|
|
case DynamicDateCard.TYPE.MONTH: |
|
|
|
|
return [{ |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Current_Day"), |
|
|
|
|
value: DynamicDateCard.OFFSET.CURRENT, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Month_Begin"), |
|
|
|
|
value: DynamicDateCard.OFFSET.BEGIN, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Month_End"), |
|
|
|
|
value: DynamicDateCard.OFFSET.END, |
|
|
|
|
}]; |
|
|
|
|
} |
|
|
|
|
]; |
|
|
|
|
case DynamicDateCard.TYPE.WEEK: |
|
|
|
|
default: |
|
|
|
|
return [{ |
|
|
|
|
return [ |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Current_Day"), |
|
|
|
|
value: DynamicDateCard.OFFSET.CURRENT, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Week_Begin"), |
|
|
|
|
value: DynamicDateCard.OFFSET.BEGIN, |
|
|
|
|
}, { |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
text: i18nText("BI-Basic_Week_End"), |
|
|
|
|
value: DynamicDateCard.OFFSET.END, |
|
|
|
|
}]; |
|
|
|
|
} |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -297,22 +381,22 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
const valueMap = {}; |
|
|
|
|
switch (value.dateType) { |
|
|
|
|
case DynamicDateCard.TYPE.YEAR: |
|
|
|
|
valueMap.year = (value.offset === 0 ? -value.value : +value.value); |
|
|
|
|
valueMap.year = value.offset === 0 ? -value.value : +value.value; |
|
|
|
|
break; |
|
|
|
|
case DynamicDateCard.TYPE.QUARTER: |
|
|
|
|
valueMap.quarter = (value.offset === 0 ? -value.value : +value.value); |
|
|
|
|
valueMap.quarter = value.offset === 0 ? -value.value : +value.value; |
|
|
|
|
break; |
|
|
|
|
case DynamicDateCard.TYPE.MONTH: |
|
|
|
|
valueMap.month = (value.offset === 0 ? -value.value : +value.value); |
|
|
|
|
valueMap.month = value.offset === 0 ? -value.value : +value.value; |
|
|
|
|
break; |
|
|
|
|
case DynamicDateCard.TYPE.WEEK: |
|
|
|
|
valueMap.week = (value.offset === 0 ? -value.value : +value.value); |
|
|
|
|
valueMap.week = value.offset === 0 ? -value.value : +value.value; |
|
|
|
|
break; |
|
|
|
|
case DynamicDateCard.TYPE.DAY: |
|
|
|
|
valueMap.day = (value.offset === 0 ? -value.value : +value.value); |
|
|
|
|
valueMap.day = value.offset === 0 ? -value.value : +value.value; |
|
|
|
|
break; |
|
|
|
|
case DynamicDateCard.TYPE.WORK_DAY: |
|
|
|
|
valueMap.workDay = (value.offset === 0 ? -value.value : +value.value); |
|
|
|
|
valueMap.workDay = value.offset === 0 ? -value.value : +value.value; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
@ -382,7 +466,7 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
} |
|
|
|
|
if (this.workDayBox.isSelected()) { |
|
|
|
|
const value = buttons[0].getValue(); |
|
|
|
|
valueMap.workDay = (value.offset === 0 ? -value.value : +value.value); |
|
|
|
|
valueMap.workDay = value.offset === 0 ? -value.value : +value.value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return valueMap; |
|
|
|
@ -393,7 +477,8 @@ export class DynamicDateCard extends Widget {
|
|
|
|
|
const start = parseDateTime(o.min, "%Y-%X-%d"); |
|
|
|
|
const end = parseDateTime(o.max, "%Y-%X-%d"); |
|
|
|
|
|
|
|
|
|
return i18nText("BI-Basic_Date_Range_Error", |
|
|
|
|
return i18nText( |
|
|
|
|
"BI-Basic_Date_Range_Error", |
|
|
|
|
start.getFullYear(), |
|
|
|
|
start.getMonth() + 1, |
|
|
|
|
start.getDate(), |
|
|
|
|