Merge pull request #1605 from dataease/pr@dev@fix_dynamic_time

fix: 动态时间组件
This commit is contained in:
fit2cloud-chenyw 2022-01-07 14:15:33 +08:00 committed by GitHub
commit 3a4b0b3005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -114,10 +114,8 @@ class TimeDateServiceImpl extends WidgetService {
const tarYear = nowYear
if (dynamicSuffix === 'before') {
const deffMonth = nowMonth - dynamicPrefix
let diffYear = deffMonth / 12
if (deffMonth < 0) {
diffYear -= 1
}
const diffYear = Math.floor(deffMonth / 12)
return new Date(tarYear + diffYear, nowMonth - dynamicPrefix % 12, nowDate).getTime()
} else {
const deffMonth = nowMonth + dynamicPrefix

View File

@ -1,5 +1,5 @@
<template>
<div v-if="element">
<div v-if="element" class="default-value-div">
<el-form ref="form" :model="element.options.attrs.default" label-width="100px">
<el-form-item :label="$t('dynamic_time.set_default')">
@ -23,7 +23,7 @@
<div class="inline">
<el-form-item v-if="element.options.attrs.default.isDynamic && element.options.attrs.default.dkey === 3" label="">
<el-input v-model="element.options.attrs.default.dynamicPrefix" type="number" size="mini" :min="1" :max="10" @input="dynamicPrefixChange" />
<el-input v-model="element.options.attrs.default.dynamicPrefix" type="number" size="mini" :min="1" :max="12" @input="dynamicPrefixChange" />
</el-form-item>
<el-form-item v-if="element.options.attrs.default.isDynamic && element.options.attrs.default.dkey === 3" label="" class="no-label-item">
@ -126,6 +126,11 @@ export default {
min-width: 70px;
}
}
.inline{
.el-form-item {
margin-bottom: 5px !important;
}
}
.relative-time {
width: 100%;
}

View File

@ -78,6 +78,8 @@ export default {
.box-card {
width: 100%;
height: 100%;
max-height: 100%;
overflow-y: scroll;
}
</style>