From d1c9bd32d5c6b7d0d9940486944f0e18c306a882 Mon Sep 17 00:00:00 2001 From: lishenfeng Date: Wed, 2 Apr 2025 10:33:03 +0800 Subject: [PATCH] =?UTF-8?q?fix():=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/TestLine2/drpOption.js | 6 +++--- src/views/TestLine2/index.js | 23 +++++++++++------------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/views/TestLine2/drpOption.js b/src/views/TestLine2/drpOption.js index 5d3bad3..614cdb1 100644 --- a/src/views/TestLine2/drpOption.js +++ b/src/views/TestLine2/drpOption.js @@ -13,7 +13,7 @@ export default function drpOption(predict = [], history = [], type) { // 雨量 const mindrp = Math.floor(Math.min(...history.map(item => item.rains))) const maxdrp = Math.ceil(Math.max(...history.map(item => item.rains))) - + // // 水位 // const minRz = Math.floor(Math.min(...data.map(item => item.water),...data.map(item => item.predict))) // const maxRz = Math.ceil(Math.max(...data.map(item => item.water),...data.map(item => item.predict))) @@ -192,9 +192,9 @@ export default function drpOption(predict = [], history = [], type) { type: "bar", // color: '#F59A23', barWidth:3, - yAxisIndex: 1, + yAxisIndex: 0, showSymbol: false, - data: [[predict[0]?.tm, maxdrp]], + data: [[predict[0]?.tm, maxRz]], tooltip: { show:false }, diff --git a/src/views/TestLine2/index.js b/src/views/TestLine2/index.js index 7966b95..9d5804a 100644 --- a/src/views/TestLine2/index.js +++ b/src/views/TestLine2/index.js @@ -24,6 +24,8 @@ export default function TestLine() { const [loading, setLoading] = useState(false) const options = useMemo(() => { if (searchVal.code) { + console.log(predictData,historyData); + return drpOption(predictData, historyData,searchVal.code) } }, [predictData, historyData,searchVal]) @@ -159,7 +161,7 @@ const handlePredictRainfallChanges =(data, value, index) => { const [predictRainfalling, setPredictRainfalling] = useState({}); const [tableUpdata, setTableUpdata] = useState([]) const tableUpdataRef = useRef(null); - tableUpdataRef.current = tableUpdata; + // tableUpdataRef.current = tableUpdata; const handleRainfallChange = (value, index) => { setPredictRainfalling(prev => ({ ...prev, @@ -173,7 +175,6 @@ const handlePredictRainfallChanges =(data, value, index) => { const getHistoryData = async (params) => { params.stcd = obj[params.code]; params.predictRainfallList = tableUpdataRef.current; - // debugger if (tableUpdataRef.current.length && tableUpdataRef.current.some(item => item.predictRainfall === '' || item.predictRainfall == null || item.predictRainfall == undefined)) { message.warning(`请输入${searchVal.time}个预测雨量值`) return @@ -205,7 +206,7 @@ const handlePredictRainfallChanges =(data, value, index) => { setLoading(false) setPredictData(res.map(item => ({ ...item, predict: item.predict.toFixed(2) }))) const tableData = res.map(item => { - const obj = needData.find(it => it.tm == item.tm) + const obj = responseData.find(it => it.tm == item.tm) return { ...item, predict: item.predict ? item.predict.toFixed(2) : '', @@ -214,6 +215,8 @@ const handlePredictRainfallChanges =(data, value, index) => { predictRainfall:type == 2 ? obj?.predictRainfall:'' } }) + console.log("tableData",tableData); + setTableList(tableData) } } @@ -222,14 +225,7 @@ const handlePredictRainfallChanges =(data, value, index) => { } } - const replaceLastItem = (arr, newValue) => { - if (!Array.isArray(arr) || arr.length === 0) { - return [newValue]; - } - const newArr = [...arr]; - newArr[newArr.length - 1] = newValue; - return newArr; - }; + /** * 处理预测结果 * @param {Array} batches - 批次数据 @@ -332,8 +328,11 @@ const handlePredictRainfallChanges =(data, value, index) => { tm:moment(searchVal.etm).add(index + 1, 'hours').format('YYYY-MM-DD HH:00:00') } })] + } - }, [searchVal.etm]) + }, [searchVal.etm,searchVal.code]) + + useEffect(() => {