forked from github/dataease
feat(查询组件): 日期查询组件可设置查询的起始日期 #6005
This commit is contained in:
parent
412025fb7f
commit
a3160e5eba
@ -40,10 +40,18 @@ const props = defineProps({
|
|||||||
const { config } = toRefs(props)
|
const { config } = toRefs(props)
|
||||||
|
|
||||||
const timeConfig = computed(() => {
|
const timeConfig = computed(() => {
|
||||||
const { relativeToCurrent, intervalType, timeNum, relativeToCurrentType, around } = config.value
|
const {
|
||||||
|
relativeToCurrent,
|
||||||
|
regularOrTrends,
|
||||||
|
intervalType,
|
||||||
|
timeNum,
|
||||||
|
relativeToCurrentType,
|
||||||
|
around
|
||||||
|
} = config.value
|
||||||
return {
|
return {
|
||||||
relativeToCurrent,
|
relativeToCurrent,
|
||||||
timeNum,
|
timeNum,
|
||||||
|
regularOrTrends,
|
||||||
intervalType,
|
intervalType,
|
||||||
relativeToCurrentType,
|
relativeToCurrentType,
|
||||||
around,
|
around,
|
||||||
@ -69,7 +77,14 @@ const timeInterval = computed<DatePickType>(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
const { relativeToCurrent, timeNum, relativeToCurrentType, around } = timeConfig.value
|
const { relativeToCurrent, regularOrTrends, timeNum, relativeToCurrentType, around } =
|
||||||
|
timeConfig.value
|
||||||
|
if (regularOrTrends === 'fixed') {
|
||||||
|
if (!!config.value.regularOrTrendsValue && !Array.isArray(config.value.regularOrTrendsValue))
|
||||||
|
return
|
||||||
|
config.value.regularOrTrendsValue = new Date()
|
||||||
|
return
|
||||||
|
}
|
||||||
if (relativeToCurrent === 'custom') {
|
if (relativeToCurrent === 'custom') {
|
||||||
config.value.regularOrTrendsValue = getAround(
|
config.value.regularOrTrendsValue = getAround(
|
||||||
relativeToCurrentType,
|
relativeToCurrentType,
|
||||||
|
@ -51,6 +51,7 @@ const timeConfig = computed(() => {
|
|||||||
relativeToCurrentType,
|
relativeToCurrentType,
|
||||||
around,
|
around,
|
||||||
intervalType,
|
intervalType,
|
||||||
|
regularOrTrends,
|
||||||
timeGranularity,
|
timeGranularity,
|
||||||
timeNumRange,
|
timeNumRange,
|
||||||
relativeToCurrentTypeRange,
|
relativeToCurrentTypeRange,
|
||||||
@ -61,6 +62,7 @@ const timeConfig = computed(() => {
|
|||||||
relativeToCurrentType,
|
relativeToCurrentType,
|
||||||
around,
|
around,
|
||||||
intervalType,
|
intervalType,
|
||||||
|
regularOrTrends,
|
||||||
timeGranularity,
|
timeGranularity,
|
||||||
timeNumRange,
|
timeNumRange,
|
||||||
relativeToCurrentTypeRange,
|
relativeToCurrentTypeRange,
|
||||||
@ -89,11 +91,25 @@ const init = () => {
|
|||||||
timeNum,
|
timeNum,
|
||||||
relativeToCurrentType,
|
relativeToCurrentType,
|
||||||
around,
|
around,
|
||||||
|
regularOrTrends,
|
||||||
timeNumRange,
|
timeNumRange,
|
||||||
relativeToCurrentTypeRange,
|
relativeToCurrentTypeRange,
|
||||||
aroundRange
|
aroundRange
|
||||||
} = timeConfig.value
|
} = timeConfig.value
|
||||||
|
|
||||||
|
if (regularOrTrends === 'fixed') {
|
||||||
|
if (
|
||||||
|
Array.isArray(config.value.regularOrTrendsValue) &&
|
||||||
|
!!config.value.regularOrTrendsValue.length
|
||||||
|
)
|
||||||
|
return
|
||||||
|
config.value.regularOrTrendsValue = [
|
||||||
|
getAround(relativeToCurrentTypeRange, 'add', 0),
|
||||||
|
getAround(relativeToCurrentTypeRange, 'add', 1)
|
||||||
|
]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const startTime = getAround(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum)
|
const startTime = getAround(relativeToCurrentType, around === 'f' ? 'subtract' : 'add', timeNum)
|
||||||
const endTime = getAround(
|
const endTime = getAround(
|
||||||
relativeToCurrentTypeRange,
|
relativeToCurrentTypeRange,
|
||||||
|
Loading…
Reference in New Issue
Block a user