Merge pull request #7781 from dataease/pr@dev-v2_dzz

Pr@dev v2 dzz
This commit is contained in:
dataeaseShu 2024-01-24 10:54:17 +08:00 committed by GitHub
commit 07c8166e6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 97 additions and 12 deletions

View File

@ -52,6 +52,7 @@ const timeConfig = computed(() => {
const {
timeNum,
relativeToCurrentType,
timeGranularityMultiple,
around,
defaultValueCheck,
arbitraryTime,
@ -65,6 +66,7 @@ const timeConfig = computed(() => {
timeNum,
relativeToCurrentType,
around,
timeGranularityMultiple,
defaultValueCheck,
arbitraryTime,
timeGranularity,
@ -108,6 +110,7 @@ const init = () => {
defaultValueCheck,
arbitraryTime,
timeGranularity,
timeGranularityMultiple,
timeNumRange,
relativeToCurrentTypeRange,
aroundRange,
@ -123,15 +126,20 @@ const init = () => {
relativeToCurrentType,
timeGranularity,
around,
arbitraryTime
arbitraryTime,
timeGranularityMultiple,
'start-config'
)
const endTime = getCustomTime(
timeNumRange,
relativeToCurrentTypeRange,
timeGranularity,
aroundRange,
arbitraryTimeRange
arbitraryTimeRange,
timeGranularityMultiple,
'end-config'
)
selectValue.value = [startTime, endTime]
}

View File

@ -290,6 +290,7 @@ const validate = () => {
timeNum,
relativeToCurrentType,
around,
timeGranularityMultiple,
arbitraryTime,
timeGranularity,
timeNumRange,
@ -303,14 +304,18 @@ const validate = () => {
relativeToCurrentType,
timeGranularity,
around,
arbitraryTime
arbitraryTime,
timeGranularityMultiple,
'start-config'
)
const endTime = getCustomTime(
timeNumRange,
relativeToCurrentTypeRange,
timeGranularity,
aroundRange,
arbitraryTimeRange
arbitraryTimeRange,
timeGranularityMultiple,
'end-config'
)
if (+startTime > +endTime) {
ElMessage.error('结束时间必须大于开始时间!')

View File

@ -45,14 +45,34 @@ function getYearBeginning() {
return new Date(`${date.getFullYear()}/1/1`)
}
function getYearMonthRange(result, flag, sort) {
const [direction, scene] = (sort || '').split('-')
const [dateTimeType] = (flag || '').split('range')
if (direction === 'start') {
return result
} else if (direction === 'end') {
if (scene === 'config') {
return result
} else if (scene === 'panel') {
return new Date(
+getCustomTime(1, dateTimeType, dateTimeType, 'b', null, flag, 'start-config', result) -
1000
)
}
}
}
function getCustomTime(
timeNum: number,
timeType: string,
timeGranularity: string,
around: string,
arbitraryTime?: Date
arbitraryTime?: Date,
timeGranularityMultiple?: string,
sort?: string,
withDate?: Date
) {
const date = new Date()
const date = withDate ? new Date(withDate) : new Date()
const num = around === 'f' ? -timeNum : timeNum
const year = date.getFullYear()
const month = date.getMonth() + 1
@ -77,6 +97,15 @@ function getCustomTime(
resultYear = new Date(date.getTime() + 24 * 60 * 60 * 1000 * num).getFullYear()
}
switch (timeGranularityMultiple) {
case 'monthrange':
return getYearMonthRange(new Date(`${resultYear}/${resultMonth}/1`), 'monthrange', sort)
case 'yearrange':
return getYearMonthRange(new Date(`${resultYear}/1`), 'yearrange', sort)
default:
break
}
if (!!arbitraryTime) {
const time = new Date(arbitraryTime)
time.setFullYear(resultYear)
@ -92,6 +121,10 @@ function getCustomTime(
return new Date(`${resultYear}/${resultMonth}/1`)
case 'date':
return new Date(`${resultYear}/${resultMonth}/${resultDate}`)
case 'monthrange':
return new Date(`${resultYear}/${resultMonth}/1`)
case 'yearrange':
return new Date(`${resultYear}/1`)
default:
break
}

View File

@ -4,12 +4,41 @@ import { getDynamicRange, getCustomTime } from '@/custom-component/v-query/time-
const dvMainStore = dvMainStoreWithOut()
const { componentData } = storeToRefs(dvMainStore)
const forMatterValue = (type: number, selectValue: any, timeGranularity: string) => {
const getDynamicRangeTime = (type: number, selectValue: any, timeGranularityMultiple: string) => {
const timeType = (timeGranularityMultiple || '').split('range')[0]
if (timeGranularityMultiple === 'datetimerange' || type === 1 || !timeType) {
return selectValue.map(ele => +new Date(ele))
}
const [start, end] = selectValue
return [
+new Date(start),
+getCustomTime(
1,
timeType,
timeType,
'b',
null,
timeGranularityMultiple,
'start-config',
new Date(end)
) - 1000
]
}
const forMatterValue = (
type: number,
selectValue: any,
timeGranularity: string,
timeGranularityMultiple: string
) => {
if (![1, 7].includes(type)) {
return Array.isArray(selectValue) ? selectValue : [selectValue]
}
return Array.isArray(selectValue)
? selectValue.map(ele => +new Date(ele))
? getDynamicRangeTime(type, selectValue, timeGranularityMultiple)
: getRange(selectValue, timeGranularity)
}
@ -90,6 +119,7 @@ export const searchQuery = (queryComponentList, filter, curComponentId, firstLoa
let selectValue = ''
const {
selectValue: value,
timeGranularityMultiple,
parametersStart,
parametersEnd,
defaultValueCheck,
@ -118,6 +148,7 @@ export const searchQuery = (queryComponentList, filter, curComponentId, firstLoa
timeNumRange,
relativeToCurrentTypeRange,
aroundRange,
timeGranularityMultiple,
arbitraryTimeRange
} = item
@ -126,16 +157,19 @@ export const searchQuery = (queryComponentList, filter, curComponentId, firstLoa
relativeToCurrentType,
timeGranularity,
around,
arbitraryTime
arbitraryTime,
timeGranularityMultiple,
'start-panel'
)
const endTime = getCustomTime(
timeNumRange,
relativeToCurrentTypeRange,
timeGranularity,
aroundRange,
arbitraryTimeRange
arbitraryTimeRange,
timeGranularityMultiple,
'end-panel'
)
item.defaultValue = [startTime, endTime]
item.selectValue = [startTime, endTime]
}
@ -152,7 +186,12 @@ export const searchQuery = (queryComponentList, filter, curComponentId, firstLoa
!!selectValue?.length ||
Object.prototype.toString.call(selectValue) === '[object Date]'
) {
const values = forMatterValue(+displayType, selectValue, timeGranularity)
const values = forMatterValue(
+displayType,
selectValue,
timeGranularity,
timeGranularityMultiple
)
filter.push({
componentId: ele.id,
fieldId: item.checkedFieldsMap[curComponentId],