Merge pull request #11648 from dataease/pr@dev-v2_st

fix(仪表板): 图表过滤器动态时间没有保存后没有记录
This commit is contained in:
dataeaseShu 2024-08-20 09:55:00 +08:00 committed by GitHub
commit 11f4f4db59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 68 additions and 3 deletions

View File

@ -2,6 +2,7 @@
import { ElMessage } from 'element-plus-secondary'
import { inject, computed, ref, nextTick, provide } from 'vue'
import RowAuth from '@/views/chart/components/editor/filter/auth-tree/RowAuth.vue'
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
const emits = defineEmits(['filter-data'])
const filedList = inject('filedList', () => [])
@ -21,6 +22,7 @@ provide('filedList', computedFiledList)
const closeFilter = () => {
dialogVisible.value = false
}
const snapshotStore = snapshotStoreWithOut()
const submit = () => {
rowAuth.value.submit()
@ -38,6 +40,7 @@ const changeFilter = val => {
}
dfsTreeDelete(items)
emits('filter-data', { logic, items })
snapshotStore.recordSnapshotCache()
dialogVisible.value = false
}

View File

@ -93,6 +93,69 @@ const errorDetected = ({
}
}
}
const getTimeValue = dynamicTimeSetting => {
const relativeToCurrentTypeMap = {
year: '年',
month: '月',
date: '日',
datetime: '日'
}
let timeValue = ''
const {
timeGranularity,
timeNum,
relativeToCurrentType,
around,
arbitraryTime,
relativeToCurrent
} = dynamicTimeSetting || {}
if (relativeToCurrent !== 'custom') {
timeValue = [
{
label: '今年',
value: 'thisYear'
},
{
label: '去年',
value: 'lastYear'
},
{
label: '本月',
value: 'thisMonth'
},
{
label: '上月',
value: 'lastMonth'
},
{
label: '今天',
value: 'today'
},
{
label: '昨天',
value: 'yesterday'
},
{
label: '月初',
value: 'monthBeginning'
},
{
label: '年初',
value: 'yearBeginning'
}
].find(ele => ele.value === relativeToCurrent).label
return timeValue
}
timeValue = `${timeNum}${relativeToCurrentTypeMap[relativeToCurrentType]}${
around === 'f' ? '前' : '后'
}`
if (timeGranularity === 'datetime') {
timeValue += new Date(arbitraryTime).toLocaleString().split(' ')[1]
}
return timeValue
}
const dfsInit = arr => {
const elementList = []
arr.forEach(ele => {
@ -104,7 +167,6 @@ const dfsInit = arr => {
} else {
const {
enumValue,
timeValue,
filterTypeTime,
dynamicTimeSetting,
fieldId,
@ -119,7 +181,7 @@ const dfsInit = arr => {
fieldId,
filterType,
term,
timeValue,
timeValue: getTimeValue(dynamicTimeSetting),
filterTypeTime,
dynamicTimeSetting,
value,
@ -162,7 +224,7 @@ const dfsSubmit = arr => {
name,
timeValue
} = ele
errorDetected({ deType, enumValue, filterType, term, value, name, timeValue })
errorDetected({ deType, enumValue, filterType, term, value, name, timeValue, filterTypeTime })
if (fieldId) {
items.push({
enumValue: enumValue ? enumValue.split(',') : [],