From a6012476b01e24494e16ef1808ed89274aaa45f9 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Tue, 24 Oct 2023 19:39:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=98=88=E5=80=BC/=E8=BE=85=E5=8A=A9?= =?UTF-8?q?=E7=BA=BF=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/manage/ChartDataManage.java | 8 ++- .../src/models/chart/chart-senior.d.ts | 19 +++++- .../editor/editor-senior/Senior.vue | 33 +++++++--- .../editor-senior/components/AssistLine.vue | 63 +++++++++---------- .../editor-senior/components/Threshold.vue | 27 ++++---- .../components/dialog/TableThresholdEdit.vue | 2 +- .../editor-style/components/LabelSelector.vue | 2 +- .../editor-style/components/MiscSelector.vue | 4 +- .../views/chart/components/editor/index.vue | 2 +- .../chart/components/editor/util/chart.ts | 7 ++- .../js/panel/charts/others/gauge.ts | 2 +- .../components/js/panel/common/common_antv.ts | 20 ++++-- .../js/panel/common/common_table.ts | 6 +- .../views/components/ChartComponentG2Plot.vue | 2 +- .../chart/dto/ChartSeniorAssistCfgDTO.java | 11 ++++ 15 files changed, 130 insertions(+), 78 deletions(-) create mode 100644 sdk/api/api-base/src/main/java/io/dataease/api/chart/dto/ChartSeniorAssistCfgDTO.java diff --git a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java index 7aae62ade0..d74064398a 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java +++ b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java @@ -821,9 +821,11 @@ public class ChartDataManage { return list; } - String assistLine = (String) JsonUtil.toJSONString(senior.get("assistLine")); - List assistLines = JsonUtil.parseList(assistLine, new TypeReference<>() { - }); + var assistLineCfg = JsonUtil.parseObject((String) JsonUtil.toJSONString(senior.get("assistLineCfg")), ChartSeniorAssistCfgDTO.class); + if (null == assistLineCfg || !assistLineCfg.isEnable()) { + return list; + } + List assistLines = assistLineCfg.getAssistLine(); if (ObjectUtils.isEmpty(assistLines)) { return list; diff --git a/core/core-frontend/src/models/chart/chart-senior.d.ts b/core/core-frontend/src/models/chart/chart-senior.d.ts index dc16c49047..610b5f2467 100644 --- a/core/core-frontend/src/models/chart/chart-senior.d.ts +++ b/core/core-frontend/src/models/chart/chart-senior.d.ts @@ -9,7 +9,7 @@ declare interface ChartSenior { /** * 辅助线 */ - assistLine: AssistLine[] + assistLineCfg: ChartAssistLineCfg /** * 阈值 */ @@ -61,6 +61,19 @@ declare interface ChartFunctionCfg { /** * 辅助线设置 */ +declare interface ChartAssistLineCfg { + /** + * 是否启用 + */ + enable: boolean + /** + * 辅助线配置 + */ + assistLine: AssistLine[] +} +/** + * 辅助线 + */ declare interface AssistLine { /** * 辅助线名称 @@ -100,6 +113,10 @@ declare interface AssistLine { * 阈值设置 */ declare interface ChartThreshold { + /** + * 是否启用 + */ + enable: boolean /** * 仪表盘阈值: x,y,z */ diff --git a/core/core-frontend/src/views/chart/components/editor/editor-senior/Senior.vue b/core/core-frontend/src/views/chart/components/editor/editor-senior/Senior.vue index 5dc2aaf5b5..eac2f1b597 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-senior/Senior.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-senior/Senior.vue @@ -5,7 +5,7 @@ import ScrollCfg from '@/views/chart/components/editor/editor-senior/components/ import AssistLine from '@/views/chart/components/editor/editor-senior/components/AssistLine.vue' import Threshold from '@/views/chart/components/editor/editor-senior/components/Threshold.vue' import CollapseSwitchItem from '@/components/collapse-switch-item/src/CollapseSwitchItem.vue' -import { computed, PropType, ref, toRefs } from 'vue' +import { computed, PropType, ref, toRefs, watch } from 'vue' import LinkJumpSet from '@/components/visualization/LinkJumpSet.vue' import LinkageSet from '@/components/visualization/LinkageSet.vue' import { canvasSave } from '@/utils/canvasUtils' @@ -15,6 +15,8 @@ import { updateLinkageActive } from '@/api/visualization/linkage' import { includesAny } from '../util/StringUtils' import { ElIcon, ElMessage } from 'element-plus-secondary' import { storeToRefs } from 'pinia' +import { BASE_VIEW_CONFIG } from '../util/chart' +import { cloneDeep, defaultsDeep } from 'lodash-es' const dvMainStore = dvMainStoreWithOut() const { dvInfo } = storeToRefs(dvMainStore) @@ -70,7 +72,12 @@ const props = defineProps({ }) const { chart, themes, properties, propertyInnerAll } = toRefs(props) - +watch( + () => chart.value?.senior, + () => { + chart.value.senior = defaultsDeep(chart.value?.senior || {}, cloneDeep(BASE_VIEW_CONFIG.senior)) + } +) const seniorCounts = computed(() => { let linkageCount = 0 let jumpCount = 0 @@ -187,11 +194,14 @@ const linkageActiveChange = () => { /> - { :property-inner="propertyInnerAll['assist-line']" @onAssistLineChange="onAssistLineChange" /> - + { /> - { :property-inner="propertyInnerAll['threshold']" @onThresholdChange="onThresholdChange" /> - + , required: true }, quotaData: { @@ -32,28 +33,26 @@ const quotaFields = computed>(() => { }) const state = reactive({ - assistLine: [], + assistLineCfg: { + enable: false, + assistLine: [] + }, editLineDialog: false, lineArr: [], quotaFields: [] }) watch( - () => props.chart, + () => props.chart.senior.assistLineCfg, () => { init() - } + }, + { deep: true } ) const changeAssistLine = () => { - let flag = false - const arr = state.assistLine.filter(ele => { - return ele.field === '1' - }) - if (arr && arr.length > 0) { - flag = true - } - emit('onAssistLineChange', { data: state.assistLine, requestData: flag }) + const flag = state.assistLineCfg.assistLine.findIndex(ele => ele.field === '1') !== -1 + emit('onAssistLineChange', { data: state.assistLineCfg, requestData: flag }) } const lineChange = val => { @@ -68,7 +67,6 @@ const closeEditLine = () => { } const changeLine = () => { - console.log(state.lineArr) // check line config for (let i = 0; i < state.lineArr.length; i++) { const ele = state.lineArr[i] @@ -96,35 +94,29 @@ const changeLine = () => { } } } - state.assistLine = JSON.parse(JSON.stringify(state.lineArr)) + state.assistLineCfg.assistLine = JSON.parse(JSON.stringify(state.lineArr)) changeAssistLine() closeEditLine() } function existField(line) { - return !!_.find(quotaFields.value, d => d.id === line.id) + return !!find(quotaFields.value, d => d.id === line.id) } const init = () => { const chart = JSON.parse(JSON.stringify(props.chart)) if (chart.senior) { - let senior = null - if (Object.prototype.toString.call(chart.senior) === '[object Object]') { - senior = JSON.parse(JSON.stringify(chart.senior)) - } else { - senior = JSON.parse(chart.senior) - } - if (senior.assistLine) { - for (let i = 0; i < senior.assistLine.length; i++) { - if (!senior.assistLine[i].fontSize) { - senior.assistLine[i].fontSize = '10' + const senior = chart.senior + if (senior.assistLineCfg?.assistLine) { + const assistLine = senior.assistLineCfg.assistLine + for (let i = 0; i < assistLine.length; i++) { + if (!assistLine[i].fontSize) { + assistLine[i].fontSize = 10 } } - state.assistLine = senior.assistLine - } else { - state.assistLine = [] + state.assistLineCfg = defaultsDeep(senior.assistLineCfg, DEFAULT_ASSIST_LINE_CFG) } - state.lineArr = JSON.parse(JSON.stringify(state.assistLine)) + state.lineArr = JSON.parse(JSON.stringify(state.assistLineCfg.assistLine)) } } @@ -141,16 +133,17 @@ onMounted(() => { 已设置