|
|
|
@ -30,7 +30,7 @@ export class DynamicDatePane extends Widget {
|
|
|
|
|
minDate: "1900-01-01", |
|
|
|
|
maxDate: "2099-12-31", |
|
|
|
|
supportDynamic: true, |
|
|
|
|
isShow: false, // 是否是预览状态
|
|
|
|
|
isPreview: false, // 是否是预览状态
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
@ -196,7 +196,7 @@ export class DynamicDatePane extends Widget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
created() { |
|
|
|
|
this.setValue(this.options.value, true); |
|
|
|
|
this._initValue(this.options.value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_checkValueValid(value) { |
|
|
|
@ -213,6 +213,45 @@ export class DynamicDatePane extends Widget {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_initValue(v) { |
|
|
|
|
v = v || {}; |
|
|
|
|
const type = v.type || DynamicDateCombo.Static; |
|
|
|
|
const value = v.value || v; |
|
|
|
|
|
|
|
|
|
const { isPreview } = this.options; |
|
|
|
|
let date; |
|
|
|
|
|
|
|
|
|
// 如果是初始化且是预览状态 直接打开静态页面
|
|
|
|
|
this.switcher.setValue(isPreview ? DynamicDateCombo.Static : type); |
|
|
|
|
this.dateTab.setSelect(isPreview ? DynamicDateCombo.Static : type); |
|
|
|
|
switch (type) { |
|
|
|
|
case DynamicDateCombo.Dynamic: |
|
|
|
|
if (isPreview) { |
|
|
|
|
date = DynamicDateHelper.getCalculation(value); |
|
|
|
|
this.ymd.setValue({ |
|
|
|
|
year: date.getFullYear(), |
|
|
|
|
month: date.getMonth() + 1, |
|
|
|
|
day: date.getDate(), |
|
|
|
|
}); |
|
|
|
|
} 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); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setMinDate(minDate) { |
|
|
|
|
if (this.options.minDate !== minDate) { |
|
|
|
|
this.options.minDate = minDate; |
|
|
|
@ -227,29 +266,15 @@ export class DynamicDatePane extends Widget {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setValue(v, isCreated = false) { |
|
|
|
|
setValue(v) { |
|
|
|
|
v = v || {}; |
|
|
|
|
const type = v.type || DynamicDateCombo.Static; |
|
|
|
|
const value = v.value || v; |
|
|
|
|
|
|
|
|
|
const { isShow } = this.options; |
|
|
|
|
let date; |
|
|
|
|
|
|
|
|
|
// 如果是初始化且是预览状态 直接打开静态页面
|
|
|
|
|
this.switcher.setValue(isShow && isCreated ? DynamicDateCombo.Static : type); |
|
|
|
|
this.dateTab.setSelect(isShow && isCreated ? DynamicDateCombo.Static : type); |
|
|
|
|
this.switcher.setValue(type); |
|
|
|
|
this.dateTab.setSelect(type); |
|
|
|
|
switch (type) { |
|
|
|
|
case DynamicDateCombo.Dynamic: |
|
|
|
|
if (isShow && isCreated) { |
|
|
|
|
date = DynamicDateHelper.getCalculation(value); |
|
|
|
|
this.ymd.setValue({ |
|
|
|
|
year: date.getFullYear(), |
|
|
|
|
month: date.getMonth() + 1, |
|
|
|
|
day: date.getDate(), |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
this.dynamicPane.setValue(value); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case DynamicDateCombo.Static: |
|
|
|
|
default: |
|
|
|
|