import {ref} from "vue" import {searchStatisticCreate, searchStatisticSum} from "@/views/moudle/carInfo/apis"; import getRecentDay from "@/util/getRecentDay"; /** * 最近几天在线车辆数 * @return {{todayCarNum: Ref>, getRecentDaysCarNum: (function(*): Promise<*[]>)}} */ export const recentDaysCarModule = ()=>{ const todayCarNum = ref(0); /** * 查询最近几天车辆在线数 * @param num 天数 * @return {Promise<*[]>} */ const getRecentDaysCarNum = async (num)=>{ try { const res = await searchStatisticCreate(); const rs = res.data; let data = []; if(rs.code === 1) { data = rs.data; } let recentDays = getRecentDay(num); for(let i=0; i), totalCarNum: Ref>}} */ export const totalCarNumModule = ()=>{ const totalCarNum = ref(0); /** * 获取车辆的总数 * @return {Promise} */ const getTotalCarNum = async ()=>{ try { const res = await searchStatisticSum(); const rs = res.data; let num = 0; if(rs.code === 1) { num = rs.data; } totalCarNum.value = num; return num; }catch (e) { console.log(e); return 0; } } return { totalCarNum, getTotalCarNum }; }