CN-599 feat: 新报告大部分功能

This commit is contained in:
chenjinsong
2022-06-08 15:31:41 +08:00
parent 5b811997cc
commit 996adc1483
14 changed files with 665 additions and 235 deletions

View File

@@ -1,16 +1,6 @@
import _ from 'lodash'
import { storageKey } from '@/utils/constants'
// 获取初始化时间
/* Date.prototype.setStart = function () {
this.setHours(0)
this.setMinutes(0)
this.setSeconds(0)
}
Date.prototype.setEnd = function () {
this.setHours(23)
this.setMinutes(59)
this.setSeconds(59)
} */
// 将时间转化为秒
export function getSecond (time) {
const ms = getMillisecond(time)
@@ -20,17 +10,23 @@ export function getSecond (time) {
export function getMillisecond (time) {
let ms = null
if (_.isDate(time)) {
ms = time.getTime()
ms = window.$dayJs.tz(new Date(time)).valueOf()
} else if (_.isNumber(time)) {
const timeStr = _.toString(time)
const difference = timeStr.length - 13
if (difference >= 0) {
ms = timeStr.slice(0, 13)
ms = window.$dayJs.tz(new Date(Number(timeStr.slice(0, 13)))).valueOf()
} else {
ms = Math.floor(time * (10 ** (0 - difference)))
ms = window.$dayJs.tz(new Date(Math.floor(time * (10 ** (0 - difference))))).valueOf()
}
} else if (_.isString(time)) {
try {
ms = window.$dayJs.tz(new Date(time)).valueOf()
} catch (e) {
ms = null
}
}
return ms ? Number(ms) : null
return ms || null
}
// 初始化日期
export function getNowTime (interval) {