Merge pull request #8724 from dataease/pr@dev@fix_filter_date_dynamic

fix(过滤组件): 日期动态组件编辑状态逻辑错误
This commit is contained in:
fit2cloud-chenyw 2024-03-27 11:29:18 +08:00 committed by GitHub
commit caab07b79c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 22 deletions

View File

@ -67,8 +67,8 @@
<script>
import { ApplicationContext } from '@/utils/ApplicationContext'
import { timeSection } from '@/utils'
import dayjs from "dayjs";
import { getThisStart, getLastStart, getAround } from "@/views/panel/filter/filterMain/time-format-dayjs.js";
import dayjs from 'dayjs'
import { getThisStart, getLastStart, getAround } from '@/views/panel/filter/filterMain/time-format-dayjs.js'
import bus from '@/utils/bus'
import customInput from '@/components/widget/deWidget/customInput'
import { dateMap, years, seconds } from '@/components/widget/deWidget/serviceNameFn'
@ -299,10 +299,10 @@ export default {
regularOrTrends === 'fixed'
? regularOrTrendsValue[1]
: getAround(
relativeToCurrentTypeRange,
aroundRange === 'f' ? 'subtract' : 'add',
timeNumRange
)
relativeToCurrentTypeRange,
aroundRange === 'f' ? 'subtract' : 'add',
timeNumRange
)
return (
timeStamp < +new Date(startTime) - 1000 ||
timeStamp > +new Date(endTime) ||
@ -312,7 +312,7 @@ export default {
},
onPick: ({ minDate }) => {
this.startWindowTime = +new Date(minDate)
},
}
}
}
return null
@ -352,7 +352,7 @@ export default {
},
'defaultoptions': function(val, old) {
if (!this.element.options.attrs.default.isDynamic) {
this.values = this.fillValueDerfault()
this.values = this.fillValueDerfault(false)
this.dateChange(this.values)
return
}
@ -471,10 +471,10 @@ export default {
},
loadInit() {
this.clearTime()
if (this.refreshHandler()) {
return
}
const existLastValidFilters = this.$store.state.lastValidFilters && this.$store.state.lastValidFilters[this.element.id]
if (this.element.options.attrs.default?.isDynamic && !existLastValidFilters) {
return this.refreshHandler()
}
if (this.element.options.value || existLastValidFilters) {
this.values = this.fillValueDerfault()
this.dateChange(this.values)
@ -623,9 +623,9 @@ export default {
return timeSection(parseFloat(value), this.componentType || this.element.options.attrs.type, this.labelFormat)
}
},
fillValueDerfault() {
fillValueDerfault(useLastFilter = true) {
let defaultV = this.element.options.value === null ? '' : this.element.options.value.toString()
if (this.inDraw) {
if (this.inDraw && useLastFilter) {
let lastFilters = null
if (this.$store.state.lastValidFilters) {
lastFilters = this.$store.state.lastValidFilters[this.element.id]

View File

@ -15,7 +15,10 @@
</el-col>
</el-header>
<de-container>
<de-aside-container close class="ms-aside-container">
<de-aside-container
close
class="ms-aside-container"
>
<div
v-show="showAside"
style="width: 60px; left: 0px; top: 0px; bottom: 0px; position: absolute"
@ -1346,10 +1349,10 @@ export default {
regularOrTrends === 'fixed'
? regularOrTrendsValue[1]
: getAround(
relativeToCurrentTypeRange,
aroundRange === 'f' ? 'subtract' : 'add',
timeNumRange
)
relativeToCurrentTypeRange,
aroundRange === 'f' ? 'subtract' : 'add',
timeNumRange
)
return (
startWindowTime < +new Date(startTime) - 1000 ||
timeStamp > +new Date(endTime) ||
@ -1363,12 +1366,12 @@ export default {
const { value, attrs } = this.currentFilterCom.options
if (!!value && attrs.setTimeRange) {
const [startWindowTime, timeStamp] = attrs.default.isDynamic ? ApplicationContext.getService('timeDateRangeWidget').dynamicDateFormNow(this.currentFilterCom) : value.split(',')
if(this.isInRange(attrs, +startWindowTime, dayjs(+timeStamp)
if (this.isInRange(attrs, +startWindowTime, dayjs(+timeStamp)
.startOf('day')
.valueOf())) {
this.openMessageSuccess(this.$t('time.filter_range'), 'error')
return
}
this.openMessageSuccess(this.$t('time.filter_range'), 'error')
return
}
}
}
if (this.editType !== 'update') {