|
|
@ -30,7 +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, |
|
|
|
isShow: false, // 是否是预览状态
|
|
|
|
isPreview: false, // 是否是预览状态
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
@ -196,7 +196,7 @@ export class DynamicDatePane extends Widget { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
created() { |
|
|
|
created() { |
|
|
|
this.setValue(this.options.value, true); |
|
|
|
this._initValue(this.options.value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_checkValueValid(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) { |
|
|
|
setMinDate(minDate) { |
|
|
|
if (this.options.minDate !== minDate) { |
|
|
|
if (this.options.minDate !== minDate) { |
|
|
|
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 || {}; |
|
|
|
v = v || {}; |
|
|
|
const type = v.type || DynamicDateCombo.Static; |
|
|
|
const type = v.type || DynamicDateCombo.Static; |
|
|
|
const value = v.value || v; |
|
|
|
const value = v.value || v; |
|
|
|
|
|
|
|
this.switcher.setValue(type); |
|
|
|
const { isShow } = this.options; |
|
|
|
this.dateTab.setSelect(type); |
|
|
|
let date; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果是初始化且是预览状态 直接打开静态页面
|
|
|
|
|
|
|
|
this.switcher.setValue(isShow && isCreated ? DynamicDateCombo.Static : type); |
|
|
|
|
|
|
|
this.dateTab.setSelect(isShow && isCreated ? DynamicDateCombo.Static : type); |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
|
case DynamicDateCombo.Dynamic: |
|
|
|
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); |
|
|
|
this.dynamicPane.setValue(value); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case DynamicDateCombo.Static: |
|
|
|
case DynamicDateCombo.Static: |
|
|
|
default: |
|
|
|
default: |
|
|
|