diff --git a/core/core-frontend/src/views/chart/components/editor/index.vue b/core/core-frontend/src/views/chart/components/editor/index.vue index d21947a935..1a1546c9ac 100644 --- a/core/core-frontend/src/views/chart/components/editor/index.vue +++ b/core/core-frontend/src/views/chart/components/editor/index.vue @@ -55,7 +55,7 @@ import SortPriorityEdit from '@/views/chart/components/editor/drag-item/componen import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot' import CalcFieldEdit from '@/views/visualized/data/dataset/form/CalcFieldEdit.vue' import { getFieldName, guid } from '@/views/visualized/data/dataset/form/util' -import { cloneDeep, forEach, get, debounce, set, concat, keys } from 'lodash-es' +import { cloneDeep, forEach, get, debounce, set, concat, keys, merge } from 'lodash-es' import { deleteField, saveField } from '@/api/dataset' import { getWorldTree, listCustomGeoArea } from '@/api/map' import chartViewManager from '@/views/chart/components/js/panel' @@ -789,6 +789,12 @@ const addAxis = (e, axis: AxisType) => { axis: [view.value[axis][e.newDraggableIndex]], editType: 'add' }) + const itemNewAdd = view.value[axis][e.newDraggableIndex] + itemNewAdd['formatterCfg'] = merge( + itemNewAdd['formatterCfg'], + dvMainStore.canvasStyleData.component.formatterItem + ) + console.log('===test==1' + JSON.stringify(itemNewAdd)) } } else { if (!dup && typeValid) { @@ -800,6 +806,12 @@ const addAxis = (e, axis: AxisType) => { editType: 'add', ...(isGaugeOrLiquid ? { quotaData: quotaData } : {}) }) + const itemNewAdd = view.value[axis][e.newDraggableIndex] + itemNewAdd['formatterCfg'] = merge( + itemNewAdd['formatterCfg'], + dvMainStore.canvasStyleData.component.formatterItem + ) + console.log('===test==2' + JSON.stringify(itemNewAdd)) } } if (view.value.type === 'line') { @@ -1828,6 +1840,7 @@ const setActive = (ele, type = 'dimension') => { const deactivateChild = type === 'quota' ? activeDimension : activeQuota deactivateChild.value = [] activeChild.value = activeChild.value.some(item => item.id === ele.id) ? [] : [ele] + mergeFormatter(activeChild.value) } const setActiveCtrl = (ele, type = 'dimension') => { @@ -1841,6 +1854,7 @@ const setActiveCtrl = (ele, type = 'dimension') => { return } activeChild.value.push(ele) + mergeFormatter(activeChild.value) } const setActiveShift = (ele, type = 'dimension') => { @@ -1870,6 +1884,16 @@ const setActiveShift = (ele, type = 'dimension') => { activeChild.value = [...activeChild.value, ...dataArr.value.slice(startItx + 1, endItx + 1)] } } + mergeFormatter(activeChild.value) +} + +const mergeFormatter = ( + activeChildItems: any, + value = dvMainStore.canvasStyleData.component.formatterItem +) => { + activeChildItems.forEach(item => { + item['formatterCfg'] = merge(item['formatterCfg'], value) + }) } const isDrag = ref(false) @@ -1888,6 +1912,7 @@ const singleDragStartD = (e: DragEvent, ele, type) => { if (!activeChild.value.length) { activeChild.value = [unref(ele)] } + mergeFormatter(activeChild.value) startToMove(e, unref(activeDimension.value)) } @@ -1905,6 +1930,7 @@ const singleDragStart = (e: DragEvent, ele, type) => { if (!activeChild.value.length) { activeChild.value = [ele] } + mergeFormatter(activeChild.value) e.dataTransfer.setData( 'quota', JSON.stringify( @@ -3729,6 +3755,7 @@ const deleteChartFieldItem = id => {