|
|
|
@ -30,6 +30,7 @@ export class DynamicDatePane extends Widget {
|
|
|
|
|
minDate: "1900-01-01", |
|
|
|
|
maxDate: "2099-12-31", |
|
|
|
|
supportDynamic: true, |
|
|
|
|
isPreview: false, // 是否是预览状态
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
@ -63,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({ |
|
|
|
@ -195,7 +190,7 @@ export class DynamicDatePane extends Widget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
created() { |
|
|
|
|
this.setValue(this.options.value); |
|
|
|
|
this._initValue(this.options.value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_checkValueValid(value) { |
|
|
|
@ -212,6 +207,31 @@ export class DynamicDatePane extends Widget {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_initValue(v) { |
|
|
|
|
v = v || {}; |
|
|
|
|
const type = v.type || DynamicDateCombo.Static; |
|
|
|
|
const value = v.value || v; |
|
|
|
|
|
|
|
|
|
const { isPreview } = this.options; |
|
|
|
|
|
|
|
|
|
// 如果是初始化且是预览状态 直接打开静态页面
|
|
|
|
|
this.switcher.setValue(isPreview ? DynamicDateCombo.Static : type); |
|
|
|
|
this.dateTab.setSelect(isPreview ? DynamicDateCombo.Static : type); |
|
|
|
|
switch (type) { |
|
|
|
|
case DynamicDateCombo.Dynamic: |
|
|
|
|
if (isPreview) { |
|
|
|
|
this._setStaticValueByDynamicValue(value); |
|
|
|
|
} else { |
|
|
|
|
this.dynamicPane.setValue(value); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case DynamicDateCombo.Static: |
|
|
|
|
default: |
|
|
|
|
this._setStaticValue(value); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setMinDate(minDate) { |
|
|
|
|
if (this.options.minDate !== minDate) { |
|
|
|
|
this.options.minDate = minDate; |
|
|
|
@ -238,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(); |
|
|
|
|
|
|
|
|
|