From c6f25e034b5439ed8b41b73ea27dfb6fb90477c8 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Thu, 10 Apr 2025 18:16:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BB=AA=E8=A1=A8=E7=9B=98=E5=A4=A7=E5=B0=8F=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=8A=A8=E6=80=81=E5=AD=97=E6=AE=B5=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E9=80=89=E6=8B=A9=E8=AE=A1=E7=AE=97=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20#15693?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/numeric/NumericalChartHandler.java | 3 +- .../editor-style/components/MiscSelector.vue | 59 +++++++++++-------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/numeric/NumericalChartHandler.java b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/numeric/NumericalChartHandler.java index 62530e0fbf..1531f34ee7 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/numeric/NumericalChartHandler.java +++ b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/numeric/NumericalChartHandler.java @@ -74,7 +74,8 @@ public class NumericalChartHandler extends DefaultChartHandler { } ChartViewFieldDTO dto = new ChartViewFieldDTO(); BeanUtils.copyBean(dto, datasetTableField); - dto.setSummary(summary); + // 计算字段不支持汇总操作 + dto.setSummary(dto.getExtField() == 2 ? "" : summary); return dto; } else { DEException.throwException(Translator.get("i18n_gauge_field_delete")); diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/MiscSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/MiscSelector.vue index e5815746c4..86b9d41f2f 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/MiscSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/MiscSelector.vue @@ -95,23 +95,22 @@ const initField = () => { if (!yAxisInDataset) { return } - // 过滤掉记录数字段以及计算字段 - state.quotaData = props.quotaFields.filter(ele => ele.id !== '-1' && ele.extField !== 2) + // 过滤掉记录数字段 + state.quotaData = props.quotaFields.filter(ele => ele.id !== '-1') if (!isEmpty(state.miscForm.gaugeMinField.id)) { state.minField = getQuotaField(state.miscForm.gaugeMinField.id) + calcField(state.miscForm.gaugeMinField) } if (!isEmpty(state.miscForm.gaugeMaxField.id)) { state.maxField = getQuotaField(state.miscForm.gaugeMaxField.id) + calcField(state.miscForm.gaugeMaxField) } if (!isEmpty(state.miscForm.liquidMaxField.id)) { state.liquidMaxField = getQuotaField(state.miscForm.liquidMaxField.id) + calcField(state.miscForm.liquidMaxField) } } -const COUNT_DE_TYPE = [0, 1, 5] const NUMBER_DE_TYPE = [1, 2, 3] -const getFieldSummaryByDeType = (deType: number) => { - return COUNT_DE_TYPE.includes(deType) || !deType ? 'count' : 'sum' -} const getDynamicFieldId = () => { // 返回yAxis字段ID @@ -138,6 +137,7 @@ const changeQuotaField = (type: string, resetSummary?: boolean) => { } else { state.miscForm.gaugeMax = state.miscForm.gaugeMax || cloneDeep(defaultMaxValue.gaugeMax) } + calcField(state.miscForm.gaugeMaxField) changeMisc('gaugeMaxField', true) } if (type === 'min') { @@ -155,6 +155,7 @@ const changeQuotaField = (type: string, resetSummary?: boolean) => { } else { state.miscForm.gaugeMin = state.miscForm.gaugeMin ?? 0 } + calcField(state.miscForm.gaugeMinField) changeMisc('gaugeMinField', true) } } @@ -171,17 +172,14 @@ const changeQuotaField = (type: string, resetSummary?: boolean) => { } else { state.miscForm.liquidMax = state.miscForm.liquidMax || cloneDeep(defaultMaxValue.liquidMax) } + calcField(state.miscForm.liquidMaxField) changeMisc(`${maxValueKey}Field`, true) } } const setDynamicFieldId = fieldObj => { const yAxisField = props.chart.yAxis?.[0] - if ( - yAxisField?.extField === 2 || - yAxisField?.id === '-1' || - !NUMBER_DE_TYPE.includes(yAxisField?.deType) - ) { + if (yAxisField?.id === '-1' || !NUMBER_DE_TYPE.includes(yAxisField?.deType)) { fieldObj.id = getDynamicFieldId() } else { fieldObj.id = yAxisField?.id @@ -242,18 +240,20 @@ const initAxis = yAxisId => { if (yAxisId) { const uniqueIds = new Set(state.quotaData.map(item => item.id)) state.quotaData = [ - ...props.quotaFields.filter( - ele => ele.id !== '-1' && ele.extField !== 2 && !uniqueIds.has(ele.id) - ) + ...props.quotaFields.filter(ele => ele.id !== '-1' && !uniqueIds.has(ele.id)) ] const maxTypeKey = isLiquid.value ? 'liquidMaxType' : 'gaugeMaxType' const maxValueKey = isLiquid.value ? 'liquidMax' : 'gaugeMax' - if (state.quotaData.length) { + if ( + state.quotaData.length && + state.quotaData.find(item => item.id === yAxisId && NUMBER_DE_TYPE.includes(item.deType)) + ) { if (isLiquid.value) { state.miscForm[maxTypeKey] = 'dynamic' state.miscForm[maxValueKey + 'Field']['id'] = getDynamicFieldId() ?? state.quotaData[0]?.id state.miscForm[maxValueKey + 'Field']['summary'] = 'sum' state.liquidMaxField = getQuotaField(state.miscForm[maxValueKey + 'Field']['id']) + calcField(state.miscForm[maxValueKey + 'Field']) changeMisc(`${maxValueKey}Field`, true) } if (isGauge.value) { @@ -262,6 +262,7 @@ const initAxis = yAxisId => { state.miscForm[maxValueKey + 'Field']['id'] = getDynamicFieldId() ?? state.quotaData[0]?.id state.miscForm[maxValueKey + 'Field']['summary'] = 'sum' state.maxField = getQuotaField(state.miscForm[maxValueKey + 'Field']['id']) + calcField(state.miscForm[maxValueKey + 'Field']) changeMisc(`${maxValueKey}Field`, true) // min state.miscForm.gaugeMinType = 'fix' @@ -296,9 +297,7 @@ const initStateForm = () => { if (props.chart.yAxis?.[0]?.id) { const uniqueIds = new Set(state.quotaData.map(item => item.id)) state.quotaData = [ - ...props.quotaFields.filter( - ele => ele.id !== '-1' && ele.extField !== 2 && !uniqueIds.has(ele.id) - ) + ...props.quotaFields.filter(ele => ele.id !== '-1' && !uniqueIds.has(ele.id)) ] } const maxTypeKey = isLiquid.value ? 'liquidMaxType' : 'gaugeMaxType' @@ -313,6 +312,7 @@ const initStateForm = () => { state.miscForm[maxValueKey + 'Field']['id'] = state.quotaData[0]?.id ?? '' state.miscForm[maxValueKey + 'Field']['summary'] = 'sum' state.liquidMaxField = getQuotaField(state.miscForm[maxValueKey + 'Field']['id']) + calcField(state.miscForm[maxValueKey + 'Field']) changeMisc(`${maxValueKey}Field`, true) } else if (state.miscForm[maxTypeKey] === 'fix' && !hasFixValue && hasFixValue !== 0) { state.miscForm[maxValueKey] = cloneDeep(defaultMaxValue[maxValueKey]) ?? 0 @@ -329,6 +329,7 @@ const initStateForm = () => { state.miscForm[maxValueKey + 'Field']['id'] = state.quotaData[0]?.id ?? '' state.miscForm[maxValueKey + 'Field']['summary'] = 'sum' state.maxField = getQuotaField(state.miscForm[maxValueKey + 'Field']['id']) + calcField(state.miscForm[maxValueKey + 'Field']) changeMisc(`${maxValueKey}Field`, true) } else if (state.miscForm[maxTypeKey] === 'fix' && !hasFixValue && hasFixValue !== 0) { state.miscForm[maxValueKey] = cloneDeep(defaultMaxValue[maxValueKey]) ?? 0 @@ -343,6 +344,7 @@ const initStateForm = () => { state.miscForm.gaugeMinField.id = state.quotaData[0]?.id ?? '' state.miscForm.gaugeMinField.summary = 'sum' state.minField = getQuotaField(state.miscForm.gaugeMinField.id) + calcField(state.miscForm.gaugeMinField) changeMisc('gaugeMinField', true) } } @@ -404,6 +406,15 @@ const quotaData = computed(() => { }) const isLiquid = computed(() => props.chart.type === 'liquid') const isGauge = computed(() => props.chart.type === 'gauge') + +/* + * 计算字段不支持汇总 + */ +const calcField = fieldObj => { + if (quotaData.value?.find(item => item.id === fieldObj.id)?.extField === 2) { + fieldObj.summary = '' + } +}