UNPKG

@ued_fpi/data-visual

Version:

<br /> <br /> <div style="text-align:center"> <b style="font-size:30px">@ued_fpi/data-visual</b> <p>基于Vite4+TypeScript的Vue3大屏组件库开发框架</p> <img style="display:inline" src="https://img.shields.io/npm/v/@ued_fpi/data-visual" />

80 lines (75 loc) 3.05 kB
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const elementPlus = require('element-plus'); const dayjs = require('dayjs'); require('vue'); const messageBox = (msg, type) => { elementPlus.ElMessage({ message: msg, type: type || "warning", duration: 2e3 }); }; const install = (comp, named) => { comp.install = (app) => { const name = comp.name || comp.__name || named; app.component(name, comp); }; return comp; }; const getDateEndTime = (timeType, date) => { let resDate; if (timeType === "hour") { resDate = dayjs(date).add(1, "hours").startOf("hour").format("x"); } else if (timeType === "day") { resDate = dayjs(date).add(1, "days").startOf("day").format("x"); } else if (timeType === "week") { resDate = dayjs(date).add(1, "week").startOf("week").format("x"); } else if (timeType === "month") { resDate = dayjs(date).add(1, "month").startOf("day").format("x"); } else if (timeType === "year") { resDate = dayjs(date).add(1, "year").startOf("year").format("x"); } return resDate; }; const getAlgaeTime = (val) => { const { currentType, upToDate, currentTime, periodBeginTime, periodEndTime } = val; const isCurrentPeriod = currentType !== "dailyControl"; const beginTime = isCurrentPeriod ? dayjs(currentTime).startOf("day").valueOf() : !upToDate ? dayjs().startOf("day").valueOf() : dayjs().add(-6, "months").startOf("month").valueOf(); const endTime = isCurrentPeriod ? dayjs(currentTime).endOf("day").valueOf() : !upToDate ? dayjs().endOf("day").valueOf() : dayjs().endOf("day").valueOf(); const beginWarningTime = currentTime ? periodBeginTime : dayjs().startOf("year").valueOf(); const endWarningTime = currentTime ? periodEndTime : dayjs().endOf("year").valueOf(); const beginDayWarningTime = currentTime ? dayjs(currentTime).startOf("day").valueOf() : dayjs().startOf("day").valueOf(); const endDayWarningTime = currentTime ? dayjs(currentTime).endOf("day").valueOf() : dayjs().endOf("day").valueOf(); const beginTimeNewRange = dayjs(currentTime || void 0).add(-6, "months").startOf("month").valueOf(); const endTimeNewRange = dayjs(currentTime || void 0).endOf("day").valueOf(); return { beginTime, endTime, beginTimeNewRange, // 入境断面藻情现状 开始 endTimeNewRange, // 入境断面藻情现状 结束 isCurrentPeriod, currentTime, beginWarningTime, // 预警周期 endWarningTime, // 预警周期时间 beginDayWarningTime, // 预警当天日数据 没选择历史就显示今日 endDayWarningTime // 预警当天日数据 没选择历史就显示今日 }; }; const countDecimalPlaces = (number) => { const numberAsString = number.toString(); if (numberAsString.includes(".")) return numberAsString.split(".")[1].length; return 0; }; exports.countDecimalPlaces = countDecimalPlaces; exports.getAlgaeTime = getAlgaeTime; exports.getDateEndTime = getDateEndTime; exports.install = install; exports.messageBox = messageBox;