Merge pull request #1514 from dataease/pr@dev@fix_dynamic_date

fix: 动态日期逻辑
This commit is contained in:
fit2cloud-chenyw 2021-12-24 17:11:25 +08:00 committed by GitHub
commit 084ce57a12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -91,7 +91,7 @@ class TimeDateServiceImpl extends WidgetService {
}
if (element.options.attrs.default.dkey === 3) {
const dynamicPrefix = element.options.attrs.default.dynamicPrefix
const dynamicPrefix = parseInt(element.options.attrs.default.dynamicPrefix)
const dynamicInfill = element.options.attrs.default.dynamicInfill
const dynamicSuffix = element.options.attrs.default.dynamicSuffix
@ -130,7 +130,8 @@ class TimeDateServiceImpl extends WidgetService {
const nowMonth = now.getMonth()
const nowYear = now.getFullYear()
const nowDate = now.getDate()
return new Date(nowYear - 1, nowMonth, nowDate).getTime()
return new Date(dynamicSuffix === 'before' ? (nowYear - dynamicPrefix) : (nowYear + dynamicPrefix), nowMonth, nowDate).getTime()
}
}
}

View File

@ -98,6 +98,10 @@ export default {
},
dynamicPrefixChange(value) {
if (value < 1) {
value = 1
this.element.options.attrs.default.dynamicPrefix = 1
}
this.setDval()
},
dynamicInfillChange(value) {