Browse Source

BI-133648 feat:日期过滤控件加预览模式

research/test
chenzeyu 6 months ago
parent
commit
616fb22b79
  1. 57
      packages/fineui/src/widget/datepane/datepane.js

57
packages/fineui/src/widget/datepane/datepane.js

@ -64,17 +64,11 @@ export class DynamicDatePane extends Widget {
{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
let date;
const value = this.switcher.getValue()[0];
this.dateTab.setSelect(value);
switch (value) {
case DynamicDatePane.Static:
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
this._setStaticValueByDynamicValue(this.dynamicPane.getValue());
break;
case DynamicDatePane.Dynamic:
this.dynamicPane.setValue({
@ -219,7 +213,6 @@ export class DynamicDatePane extends Widget {
const value = v.value || v;
const { isPreview } = this.options;
let date;
// 如果是初始化且是预览状态 直接打开静态页面
this.switcher.setValue(isPreview ? DynamicDateCombo.Static : type);
@ -227,27 +220,14 @@ export class DynamicDatePane extends Widget {
switch (type) {
case DynamicDateCombo.Dynamic:
if (isPreview) {
date = DynamicDateHelper.getCalculation(value);
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
this._setStaticValueByDynamicValue(value);
} else {
this.dynamicPane.setValue(value);
}
break;
case DynamicDateCombo.Static:
default:
if (this._checkValueValid(value)) {
const date = getDate();
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
});
} else {
this.ymd.setValue(value);
}
this._setStaticValue(value);
break;
}
}
@ -278,19 +258,32 @@ export class DynamicDatePane extends Widget {
break;
case DynamicDateCombo.Static:
default:
if (this._checkValueValid(value)) {
const date = getDate();
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
});
} else {
this.ymd.setValue(value);
}
this._setStaticValue(value);
break;
}
}
_setStaticValue(value) {
if (this._checkValueValid(value)) {
const date = getDate();
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
});
} else {
this.ymd.setValue(value);
}
}
_setStaticValueByDynamicValue(value) {
const date = DynamicDateHelper.getCalculation(value);
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
}
getValue() {
const type = this.dateTab.getSelect();

Loading…
Cancel
Save