fix(图表): 修复水波图、仪表盘记录数切换动态值显示错误的问题

This commit is contained in:
jianneng-fit2cloud 2024-10-30 17:39:53 +08:00
parent 1172f79a18
commit 854c4bd501

View File

@ -111,9 +111,9 @@ const initField = () => {
} }
const initDynamicDefaultField = () => { const initDynamicDefaultField = () => {
if (state.quotaData.length > 0) { const yAxisId = props.chart.yAxis?.[0]?.id
if (yAxisId !== '-1' && state.quotaData.length) {
// quotaData chart.yAxis[0].id // quotaData chart.yAxis[0].id
const yAxisId = props.chart.yAxis?.[0]?.id
const yAxisExists = state.quotaData.find(ele => ele.id === yAxisId) const yAxisExists = state.quotaData.find(ele => ele.id === yAxisId)
// //
if (!yAxisExists && (state.miscForm.liquidMaxField.id || state.miscForm.gaugeMaxField.id)) { if (!yAxisExists && (state.miscForm.liquidMaxField.id || state.miscForm.gaugeMaxField.id)) {
@ -190,9 +190,13 @@ const initDynamicDefaultField = () => {
} }
const changeQuotaField = (type: string, resetSummary?: boolean) => { const changeQuotaField = (type: string, resetSummary?: boolean) => {
let isCountField = props.chart.yAxis?.[0]?.id === '-1'
if (type === 'min') { if (type === 'min') {
if (state.miscForm.gaugeMinType === 'dynamic') { if (state.miscForm.gaugeMinType === 'dynamic') {
if (!state.miscForm.gaugeMinField.id) { if (isCountField && state.quotaData.length) {
state.miscForm.gaugeMinField.id = state.quotaData[0]?.id
}
if (!state.miscForm.gaugeMinField.id && !isCountField) {
state.miscForm.gaugeMinField.id = props.chart.yAxis?.[0]?.id state.miscForm.gaugeMinField.id = props.chart.yAxis?.[0]?.id
} }
if (!state.miscForm.gaugeMinField.summary) { if (!state.miscForm.gaugeMinField.summary) {
@ -216,12 +220,13 @@ const changeQuotaField = (type: string, resetSummary?: boolean) => {
} }
} else if (type === 'max') { } else if (type === 'max') {
if (props.chart.type === 'liquid') { if (props.chart.type === 'liquid') {
if (isCountField && state.quotaData.length) {
state.miscForm.liquidMaxField.id = state.quotaData[0]?.id
}
if (state.miscForm.liquidMaxType === 'dynamic') { if (state.miscForm.liquidMaxType === 'dynamic') {
state.miscForm.liquidMax = undefined state.miscForm.liquidMax = undefined
} else { } else if (!state.miscForm.liquidMax) {
if (!state.miscForm.liquidMax) { state.miscForm.liquidMax = cloneDeep(defaultMaxValue.liquidMax)
state.miscForm.liquidMax = cloneDeep(defaultMaxValue.liquidMax)
}
} }
if (!state.miscForm.liquidMaxField.id) { if (!state.miscForm.liquidMaxField.id) {
state.miscForm.liquidMaxField.id = props.chart.yAxis?.[0]?.id state.miscForm.liquidMaxField.id = props.chart.yAxis?.[0]?.id
@ -238,8 +243,11 @@ const changeQuotaField = (type: string, resetSummary?: boolean) => {
} }
} else { } else {
if (state.miscForm.gaugeMaxType === 'dynamic') { if (state.miscForm.gaugeMaxType === 'dynamic') {
if (isCountField && state.quotaData.length) {
state.miscForm.gaugeMaxField.id = state.quotaData[0]?.id
}
state.miscForm.gaugeMax = undefined state.miscForm.gaugeMax = undefined
if (!state.miscForm.gaugeMaxField.id) { if (!state.miscForm.gaugeMaxField.id && !isCountField) {
state.miscForm.gaugeMaxField.id = props.chart.yAxis?.[0]?.id state.miscForm.gaugeMaxField.id = props.chart.yAxis?.[0]?.id
} }
if (!state.miscForm.gaugeMaxField.summary) { if (!state.miscForm.gaugeMaxField.summary) {