forked from github/dataease
fix(查询组件): 日期范围组件,默认值没有本月、本年等 #11283
This commit is contained in:
parent
66dc4aadaa
commit
c78f4ef398
@ -15,7 +15,7 @@ import { storeToRefs } from 'pinia'
|
|||||||
import { addQueryCriteriaConfig } from './options'
|
import { addQueryCriteriaConfig } from './options'
|
||||||
import { getCustomTime } from './time-format'
|
import { getCustomTime } from './time-format'
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { getThisStart, getLastStart, getAround } from './time-format-dayjs'
|
import { getThisStart, getLastStart, getAround, getCustomRange } from './time-format-dayjs'
|
||||||
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
|
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { fieldType } from '@/utils/attr'
|
import { fieldType } from '@/utils/attr'
|
||||||
@ -725,6 +725,7 @@ const validate = () => {
|
|||||||
timeNum,
|
timeNum,
|
||||||
relativeToCurrentType,
|
relativeToCurrentType,
|
||||||
around,
|
around,
|
||||||
|
relativeToCurrentRange,
|
||||||
timeGranularityMultiple,
|
timeGranularityMultiple,
|
||||||
arbitraryTime,
|
arbitraryTime,
|
||||||
timeGranularity,
|
timeGranularity,
|
||||||
@ -735,7 +736,7 @@ const validate = () => {
|
|||||||
timeType
|
timeType
|
||||||
} = ele
|
} = ele
|
||||||
|
|
||||||
const startTime =
|
let startTime =
|
||||||
timeType === 'dynamic'
|
timeType === 'dynamic'
|
||||||
? getCustomTime(
|
? getCustomTime(
|
||||||
timeNum,
|
timeNum,
|
||||||
@ -747,7 +748,7 @@ const validate = () => {
|
|||||||
'start-config'
|
'start-config'
|
||||||
)
|
)
|
||||||
: new Date(ele.defaultValue[0])
|
: new Date(ele.defaultValue[0])
|
||||||
const endTime =
|
let endTime =
|
||||||
timeType === 'dynamic'
|
timeType === 'dynamic'
|
||||||
? getCustomTime(
|
? getCustomTime(
|
||||||
timeNumRange,
|
timeNumRange,
|
||||||
@ -759,6 +760,9 @@ const validate = () => {
|
|||||||
'end-config'
|
'end-config'
|
||||||
)
|
)
|
||||||
: new Date(ele.defaultValue[1])
|
: new Date(ele.defaultValue[1])
|
||||||
|
if (!relativeToCurrentRange || relativeToCurrentRange === 'custom') {
|
||||||
|
;[startTime, endTime] = getCustomRange(relativeToCurrentRange)
|
||||||
|
}
|
||||||
if (+startTime > +endTime) {
|
if (+startTime > +endTime) {
|
||||||
ElMessage.error('结束时间必须大于开始时间!')
|
ElMessage.error('结束时间必须大于开始时间!')
|
||||||
return true
|
return true
|
||||||
|
@ -40,7 +40,16 @@ const submit = () => {
|
|||||||
errorMessage: errorMessage.value
|
errorMessage: errorMessage.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const errorDetected = ({ enumValue, deType, filterType, term, value, name, timeValue }) => {
|
const errorDetected = ({
|
||||||
|
enumValue,
|
||||||
|
deType,
|
||||||
|
filterType,
|
||||||
|
term,
|
||||||
|
value,
|
||||||
|
name,
|
||||||
|
timeValue,
|
||||||
|
filterTypeTime
|
||||||
|
}) => {
|
||||||
if (!name) {
|
if (!name) {
|
||||||
errorMessage.value = t('data_set.cannot_be_empty_')
|
errorMessage.value = t('data_set.cannot_be_empty_')
|
||||||
return
|
return
|
||||||
@ -64,7 +73,8 @@ const errorDetected = ({ enumValue, deType, filterType, term, value, name, timeV
|
|||||||
!term.includes('null') &&
|
!term.includes('null') &&
|
||||||
!term.includes('empty') &&
|
!term.includes('empty') &&
|
||||||
['', null, undefined].includes(timeValue) &&
|
['', null, undefined].includes(timeValue) &&
|
||||||
deType === 1
|
deType === 1 &&
|
||||||
|
filterTypeTime === 'dynamicDate'
|
||||||
) {
|
) {
|
||||||
errorMessage.value = t('chart.filter_value_can_null')
|
errorMessage.value = t('chart.filter_value_can_null')
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user