mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 13:32:18 +08:00
fix(图表): 修复仪表盘大小选项中的动态字段无法选择计算字段的问题 #15693
This commit is contained in:
committed by
jianneng-fit2cloud
parent
05f0755532
commit
c6f25e034b
@@ -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"));
|
||||
|
||||
@@ -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 = ''
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -481,7 +492,7 @@ const isGauge = computed(() => props.chart.type === 'gauge')
|
||||
:gutter="8"
|
||||
v-if="showProperty('gaugeMinField') && state.miscForm.gaugeMinType === 'dynamic'"
|
||||
>
|
||||
<el-col :span="12">
|
||||
<el-col :span="state.miscForm.gaugeMinField.summary ? 12 : 24">
|
||||
<el-form-item class="form-item" :class="'form-item-' + themes">
|
||||
<el-select
|
||||
:effect="themes"
|
||||
@@ -511,7 +522,7 @@ const isGauge = computed(() => props.chart.type === 'gauge')
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="12" v-if="state.miscForm.gaugeMinField.summary">
|
||||
<el-form-item class="form-item" :class="'form-item-' + themes">
|
||||
<el-select
|
||||
:effect="themes"
|
||||
@@ -580,7 +591,7 @@ const isGauge = computed(() => props.chart.type === 'gauge')
|
||||
:gutter="8"
|
||||
v-if="showProperty('gaugeMaxField') && state.miscForm.gaugeMaxType === 'dynamic'"
|
||||
>
|
||||
<el-col :span="12">
|
||||
<el-col :span="state.miscForm.gaugeMaxField.summary ? 12 : 24">
|
||||
<el-form-item class="form-item" :class="'form-item-' + themes">
|
||||
<el-select
|
||||
:effect="themes"
|
||||
@@ -610,7 +621,7 @@ const isGauge = computed(() => props.chart.type === 'gauge')
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="12" v-if="state.miscForm.gaugeMaxField.summary">
|
||||
<el-form-item class="form-item" :class="'form-item-' + themes">
|
||||
<el-select
|
||||
:effect="themes"
|
||||
@@ -731,7 +742,7 @@ const isGauge = computed(() => props.chart.type === 'gauge')
|
||||
:gutter="8"
|
||||
v-if="showProperty('liquidMaxField') && state.miscForm.liquidMaxType === 'dynamic'"
|
||||
>
|
||||
<el-col :span="12">
|
||||
<el-col :span="state.miscForm.liquidMaxField.summary ? 12 : 24">
|
||||
<el-form-item class="form-item" :class="'form-item-' + themes">
|
||||
<el-select
|
||||
:effect="themes"
|
||||
@@ -761,7 +772,7 @@ const isGauge = computed(() => props.chart.type === 'gauge')
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="12" v-if="state.miscForm.liquidMaxField.summary">
|
||||
<el-form-item class="form-item" :class="'form-item-' + themes">
|
||||
<el-select
|
||||
:effect="themes"
|
||||
|
||||
Reference in New Issue
Block a user