From 616fb22b795529ec04ebc2ce5595b6edcd830f15 Mon Sep 17 00:00:00 2001 From: chenzeyu Date: Mon, 11 Dec 2023 18:58:52 +0800 Subject: [PATCH] =?UTF-8?q?BI-133648=20feat=EF=BC=9A=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=A7=E4=BB=B6=E5=8A=A0=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fineui/src/widget/datepane/datepane.js | 57 ++++++++----------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/packages/fineui/src/widget/datepane/datepane.js b/packages/fineui/src/widget/datepane/datepane.js index e8f79ea3f..8ba860c66 100644 --- a/packages/fineui/src/widget/datepane/datepane.js +++ b/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();