|
|
@ -30,6 +30,7 @@ export class DynamicDatePane extends Widget { |
|
|
|
minDate: "1900-01-01", |
|
|
|
minDate: "1900-01-01", |
|
|
|
maxDate: "2099-12-31", |
|
|
|
maxDate: "2099-12-31", |
|
|
|
supportDynamic: true, |
|
|
|
supportDynamic: true, |
|
|
|
|
|
|
|
isPreview: false, // 是否是预览状态
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
@ -63,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({ |
|
|
@ -195,7 +190,7 @@ export class DynamicDatePane extends Widget { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
created() { |
|
|
|
created() { |
|
|
|
this.setValue(this.options.value); |
|
|
|
this._initValue(this.options.value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_checkValueValid(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) { |
|
|
|
setMinDate(minDate) { |
|
|
|
if (this.options.minDate !== minDate) { |
|
|
|
if (this.options.minDate !== minDate) { |
|
|
|
this.options.minDate = minDate; |
|
|
|
this.options.minDate = minDate; |
|
|
@ -238,6 +258,12 @@ export class DynamicDatePane extends Widget { |
|
|
|
break; |
|
|
|
break; |
|
|
|
case DynamicDateCombo.Static: |
|
|
|
case DynamicDateCombo.Static: |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
this._setStaticValue(value); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_setStaticValue(value) { |
|
|
|
if (this._checkValueValid(value)) { |
|
|
|
if (this._checkValueValid(value)) { |
|
|
|
const date = getDate(); |
|
|
|
const date = getDate(); |
|
|
|
this.ymd.setValue({ |
|
|
|
this.ymd.setValue({ |
|
|
@ -247,8 +273,15 @@ export class DynamicDatePane extends Widget { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.ymd.setValue(value); |
|
|
|
this.ymd.setValue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_setStaticValueByDynamicValue(value) { |
|
|
|
|
|
|
|
const date = DynamicDateHelper.getCalculation(value); |
|
|
|
|
|
|
|
this.ymd.setValue({ |
|
|
|
|
|
|
|
year: date.getFullYear(), |
|
|
|
|
|
|
|
month: date.getMonth() + 1, |
|
|
|
|
|
|
|
day: date.getDate(), |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getValue() { |
|
|
|
getValue() { |
|
|
|