From 3a4c55d4b91bac698943e07d06b8c4947048f63f Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 6 Jun 2024 18:28:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E8=A1=A8):=20=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=E6=94=AF=E6=8C=81=E7=9B=B4=E6=8E=A5=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/api/chart.ts | 12 +++ .../views/chart/components/editor/index.vue | 97 +++++++++++++++++-- 2 files changed, 99 insertions(+), 10 deletions(-) diff --git a/core/core-frontend/src/api/chart.ts b/core/core-frontend/src/api/chart.ts index 6fe87aafa0..46cc45843a 100644 --- a/core/core-frontend/src/api/chart.ts +++ b/core/core-frontend/src/api/chart.ts @@ -32,6 +32,18 @@ export const getFieldByDQ = async (id, chartId): Promise => { }) } +export const copyChartField = async (id, chartId): Promise => { + return request.post({ url: `/chart/copyField/${id}/${chartId}`, data: {} }).then(res => { + return res?.data + }) +} + +export const deleteChartField = async (id): Promise => { + return request.post({ url: `/chart/deleteField/${id}`, data: {} }).then(res => { + return res?.data + }) +} + // 通过图表对象获取数据 export const getData = async (data): Promise => { delete data.data 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 41746af7ff..2cb174ae6e 100644 --- a/core/core-frontend/src/views/chart/components/editor/index.vue +++ b/core/core-frontend/src/views/chart/components/editor/index.vue @@ -50,7 +50,7 @@ import chartViewManager from '@/views/chart/components/js/panel' import DatasetSelect from '@/views/chart/components/editor/dataset-select/DatasetSelect.vue' import { useDraggable } from '@vueuse/core' import { set, concat, keys } from 'lodash-es' -import { Field, getFieldByDQ } from '@/api/chart' +import { Field, getFieldByDQ, copyChartField, deleteChartField } from '@/api/chart' import ChartTemplateInfo from '@/views/chart/components/editor/common/ChartTemplateInfo.vue' import { XpackComponent } from '@/components/plugin' import { useEmbedded } from '@/store/modules/embedded' @@ -205,12 +205,15 @@ watch( ) const getFields = (id, chartId) => { if (id && chartId) { + fieldLoading.value = true getFieldByDQ(id, chartId) .then(res => { state.dimension = (res.dimensionList as unknown as Field[]) || [] state.quota = (res.quotaList as unknown as Field[]) || [] state.dimensionData = JSON.parse(JSON.stringify(state.dimension)) state.quotaData = JSON.parse(JSON.stringify(state.quota)) + + fieldLoading.value = false emitter.emit('dataset-change') }) .catch(() => { @@ -218,12 +221,16 @@ const getFields = (id, chartId) => { state.quota = [] state.dimensionData = [] state.quotaData = [] + + fieldLoading.value = false }) } else { state.dimension = [] state.quota = [] state.dimensionData = [] state.quotaData = [] + + fieldLoading.value = false } } @@ -1488,6 +1495,30 @@ const drop = (ev: MouseEvent, type = 'xAxis') => { } } } + +const fieldLoading = ref(false) + +const copyChartFieldItem = id => { + fieldLoading.value = true + copyChartField(id, view.value.id) + .then(() => { + getFields(view.value.tableId, view.value.id) + }) + .catch(() => { + fieldLoading.value = false + }) +} + +const deleteChartFieldItem = id => { + fieldLoading.value = true + deleteChartField(id) + .then(() => { + getFields(view.value.tableId, view.value.id) + }) + .catch(() => { + fieldLoading.value = false + }) +} -
+
{ @dragstart="$event => singleDragStartD($event, element, 'dimension')" :draggable="true" @dragend="singleDragEnd" - class="item" + class="item father" v-for="element in dimensionData" :key="element.id" > @@ -2508,9 +2543,30 @@ const drop = (ev: MouseEvent, type = 'xAxis') => { :name="`field_${fieldType[element.deType]}`" /> - {{ - element.name - }} + {{ element.name }} + + + + + + { @click.meta="setActiveCtrl(element, 'quota')" @click.exact="setActive(element, 'quota')" @click.shift="setActiveShift(element, 'quota')" - class="item" + class="item father" @dragstart="$event => singleDragStart($event, element, 'quota')" :draggable="true" @dragend="singleDragEnd" @@ -2636,9 +2692,30 @@ const drop = (ev: MouseEvent, type = 'xAxis') => { :name="`field_${fieldType[element.deType]}`" > - {{ - element.name - }} + {{ element.name }} + + + + + +