diff --git a/frontend/src/views/machine/freqConverter/components/freqConverterDipChart.vue b/frontend/src/views/machine/freqConverter/components/freqConverterDipChart.vue index 6a91668..32c9a3f 100644 --- a/frontend/src/views/machine/freqConverter/components/freqConverterDipChart.vue +++ b/frontend/src/views/machine/freqConverter/components/freqConverterDipChart.vue @@ -82,7 +82,6 @@ const CHARACTERISTIC_POINT_COLOR = '#ff4d4f' const chartPoints = ref([]) const characteristicCurveData = ref([]) -const drawnCharacteristicCurveData = ref([]) const characteristicCurveVisible = ref(false) const chartRef = ref(null) @@ -146,35 +145,12 @@ const sortedCharacteristicCurveData = computed(() => { }) }) -const sortedDrawnCharacteristicCurveData = computed(() => { - return [...drawnCharacteristicCurveData.value].sort((a, b) => { - if (a.timeMs !== null && b.timeMs !== null && a.timeMs !== b.timeMs) { - return a.timeMs - b.timeMs - } - - if (a.timeMs !== null && b.timeMs === null) { - return -1 - } - - if (a.timeMs === null && b.timeMs !== null) { - return 1 - } - - if (a.duration !== b.duration) { - return a.duration - b.duration - } - - return a.residualVoltage - b.residualVoltage - }) -}) - const solidCharacteristicCurveSeriesData = computed(() => { if (!characteristicCurveVisible.value) { return [] as Array<[number, number, string]> } - const curveSource = props.autoDrawCurve ? sortedCharacteristicCurveData.value : sortedDrawnCharacteristicCurveData.value - return curveSource.map(item => [item.duration, item.residualVoltage, '特性曲线']) + return sortedCharacteristicCurveData.value.map(item => [item.duration, item.residualVoltage, '特性曲线']) }) const characteristicCurvePointSeriesData = computed(() => { @@ -511,13 +487,11 @@ const updateCharacteristicCurveVisibility = () => { const drawCharacteristicCurve = () => { if (!sortedCharacteristicCurveData.value.length) { - drawnCharacteristicCurveData.value = [] characteristicCurveVisible.value = false ElMessage.warning('暂无特性曲线点') return } - drawnCharacteristicCurveData.value = [...sortedCharacteristicCurveData.value] characteristicCurveVisible.value = true } @@ -735,7 +709,6 @@ watch( () => props.autoDrawCurve, newValue => { characteristicCurveVisible.value = newValue ? characteristicCurveData.value.length > 0 : false - drawnCharacteristicCurveData.value = newValue ? [...characteristicCurveData.value] : [] }, { immediate: true } ) @@ -786,7 +759,6 @@ watch( () => { chartPoints.value = [] characteristicCurveData.value = [] - drawnCharacteristicCurveData.value = [] characteristicCurveVisible.value = false } ) diff --git a/frontend/src/views/machine/freqConverter/components/freqConverterTestPopup.vue b/frontend/src/views/machine/freqConverter/components/freqConverterTestPopup.vue index 25d6aa4..0a64dd7 100644 --- a/frontend/src/views/machine/freqConverter/components/freqConverterTestPopup.vue +++ b/frontend/src/views/machine/freqConverter/components/freqConverterTestPopup.vue @@ -123,6 +123,30 @@ const normalizeFormalRealPayload = (payload: any) => { } } +const extractResultArray = (payload: any) => { + if (Array.isArray(payload)) { + return payload + } + + if (Array.isArray(payload?.data)) { + return payload.data + } + + if (Array.isArray(payload?.data?.records)) { + return payload.data.records + } + + if (Array.isArray(payload?.records)) { + return payload.records + } + + if (Array.isArray(payload?.list)) { + return payload.list + } + + return [] as any[] +} + const handleSocketMessage = (payload: any) => { const requestId = `${payload?.requestId ?? ''}` const normalizedRequestId = requestId.trim().toLowerCase() @@ -289,7 +313,7 @@ const handleStart = async () => { const historyResult = await getFreqConverterResult({ converterId: mapping.freqConverterId }) - historyResultData.value = historyResult?.data ?? historyResult + historyResultData.value = extractResultArray(historyResult?.data ?? historyResult) } else { historyResultData.value = null }