forked from github/dataease
Merge pull request #11648 from dataease/pr@dev-v2_st
fix(仪表板): 图表过滤器动态时间没有保存后没有记录
This commit is contained in:
commit
11f4f4db59
@ -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
|
||||
}
|
||||
|
||||
|
@ -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(',') : [],
|
||||
|
Loading…
Reference in New Issue
Block a user