diff --git a/src/hooks/handleFun.ts b/src/hooks/handleFun.ts index d4f5d4e..d427ff7 100644 --- a/src/hooks/handleFun.ts +++ b/src/hooks/handleFun.ts @@ -1,10 +1,39 @@ // 处理一些常用的方法 + // 处理单位换算 export function handleUnit(data) { - if(Number(data) > 10000) { + if (Number(data) > 10000) { return (data / 1000).toFixed(2) - }else{ + } else { return data } +} + + + + +// 处理echarts数据 +export function handleEchartsData(data) { + // 间隔可以设置成动态的 + let timeArray = []; + for (let hour = 0; hour < 24; hour++) { + for (let minute = 0; minute < 60; minute += 5) { + let timeString = (hour < 10 ? '0' + hour : hour) + ':' + (minute < 10 ? '0' + minute : minute); + timeArray.push( + { datetime: timeString, measValue: '-' } + ); + } + } + + timeArray.forEach(item => { + data.forEach(ite => { + let iteTime = ite.datetime.split(' ')[1].split(':')[0] + ':' + ite.datetime.split(' ')[1].split(':')[1] + if (iteTime === item.datetime) { + item.measValue =ite.measValue + } + }) + }) + + return timeArray } \ No newline at end of file diff --git a/src/views/pages/homePage/runListenPage.vue b/src/views/pages/homePage/runListenPage.vue index 333fafe..99eae71 100644 --- a/src/views/pages/homePage/runListenPage.vue +++ b/src/views/pages/homePage/runListenPage.vue @@ -20,17 +20,17 @@