fix(过滤组件): 日期动态组件编辑状态逻辑错误

This commit is contained in:
fit2cloud-chenyw 2024-03-27 11:28:12 +08:00
parent 14a136453d
commit 9bdf643ed2
2 changed files with 25 additions and 22 deletions

View File

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

View File

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