Merge pull request #12625 from dataease/pr@dev-v2@refactor_view-editor

refactor(数据大屏、仪表板): 优化图表编辑区域,防止切换数据集时部分图表可能会出现多次渲染问题
This commit is contained in:
王嘉豪 2024-10-10 18:30:24 +08:00 committed by GitHub
commit bf12246701
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import { BASE_VIEW_CONFIG } from '@/views/chart/components/editor/util/chart'
import DatasetSelect from '@/views/chart/components/editor/dataset-select/DatasetSelect.vue'
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
import { useEmitt } from '@/hooks/web/useEmitt'
import { getFieldByDQ } from '@/api/chart'
const snapshotStore = snapshotStoreWithOut()
const props = defineProps({
@ -23,8 +24,21 @@ const { view } = toRefs(props)
const state = reactive({})
const onDatasetUpdate = () => {
useEmitt().emitter.emit('calcData-' + view.value.id, view)
snapshotStore.recordSnapshotCache('calc', view.value.id)
if (view.value.tableId && view.value.id) {
getFieldByDQ(view.value.tableId, view.value.id, { type: 'table-info' })
.then(res => {
view.value.xAxis = []
view.value.xAxis.push(...res.dimensionList, ...res.quotaList)
const viewTarget = view.value
useEmitt().emitter.emit('calcData-' + viewTarget.id, viewTarget)
snapshotStore.recordSnapshotCache('calc', view.value.id)
})
.catch(() => {
// something do error
})
} else {
view.value.xAxis = []
}
}
</script>

View File

@ -222,6 +222,9 @@ provide('quota', () => state.quota)
watch(
[() => view.value['tableId']],
() => {
if ('picture-group' === props.view.type) {
return
}
getFields(props.view.tableId, props.view.id, props.view.type)
const nodeId = view.value['tableId']
if (!!nodeId) {