Browse Source

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

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

Loading…
Cancel
Save