fix(): 修复bug

test1
李神峰 2025-04-02 10:33:03 +08:00
parent a6fd12bbf0
commit d1c9bd32d5
2 changed files with 14 additions and 15 deletions

View File

@ -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
},

View File

@ -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(() => {