fix: 调整时序图 x轴时间段判断调整

This commit is contained in:
zyh
2024-03-27 15:07:15 +08:00
parent 15d59758bc
commit fa2f13ad9a

View File

@@ -532,9 +532,6 @@ export default {
let minute = tData.getMinutes()
minute = minute > 9 ? minute : '0' + minute // 如果分钟小于10,则在前面加0补充为两位数字
if (minTime !== null && maxTime !== null) {
const diffSec = (maxTime - minTime)
const secOneDay = 12 * 60 * 60// 0.5天的秒数
const secOneMonth = secOneDay * 30// 30天的秒数
const dateFormatStr = self.timeFormatMain.split(' ')[0]
let str = ''
const month = tData.getMonth() + 1
@@ -546,9 +543,15 @@ export default {
} else {
str += [month, day].join('-')
}
if (diffSec <= secOneDay - 100) { // 同一天
const moment1 = moment((minTime * 1000 - localOffset + offset * 60 * 1000))
const moment2 = moment((maxTime * 1000 - localOffset + offset * 60 * 1000))
const isSameDay = moment1.isSame(moment2, 'day')
const isSameMonth = moment1.isSame(moment2, 'month')
if (isSameDay) { // 同一天
return [hour, minute].join(':')
} else if (diffSec < secOneMonth) { // 大于1天小于30天
} else if (isSameMonth) { // 同一月
return str + '\n' + [hour, minute].join(':')
} else { // 大于等于30天
return str