Commit 2ce26d3d by wusiyi

feat: 概览数据优化

parent 219f633c
......@@ -659,22 +659,6 @@ const yesterday = new Date(new Date().setDate(new Date().getDate() - 1))
})
.replace(/\//g, '-')
const lastWeek = new Date(new Date().setDate(new Date().getDate() - 7))
.toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
.replace(/\//g, '-')
const lastMonth = new Date(new Date().setMonth(new Date().getMonth() - 1))
.toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
.replace(/\//g, '-')
// 获取统计数据
const statisticData = ref<StatisticData | null>(null)
......@@ -1153,11 +1137,76 @@ const getchartTimes = async (v: string, type: string) => {
// 空数据提示文字
const generatePeriodText = (timeRange: string): string => {
if (timeRange === '0') {
return `当前周期(${yesterday}${today})暂无订单数据\n\n请在订单流转后等待数据更新查看趋势`
const startTime = new Date(new Date().setDate(new Date().getDate() - 14))
.toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
.replace(/\//g, '-')
return `当前周期(${startTime}${yesterday})暂无订单数据\n\n请在订单流转后等待数据更新查看趋势`
} else if (timeRange === '1') {
return `当前周期(${lastWeek}${today})暂无订单数据\n\n请在订单流转后等待数据更新查看趋势`
// 8周前该周周一的日期
const now = new Date()
const eightWeeksAgo = new Date(now.getTime() - 8 * 7 * 24 * 60 * 60 * 1000)
const dayOfWeek = eightWeeksAgo.getDay() // 0=周日, 1=周一, ..., 6=周六
const daysToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek // 如果是周日,往前6天;否则往前到周一
const mondayDate = new Date(
eightWeeksAgo.getTime() + daysToMonday * 24 * 60 * 60 * 1000,
)
const startTime = mondayDate
.toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
.replace(/\//g, '-')
// 上个周日的日期
const today = new Date()
const todayDayOfWeek = today.getDay() // 0=周日, 1=周一, ..., 6=周六
const daysToLastSunday = todayDayOfWeek === 0 ? -7 : -todayDayOfWeek // 如果是周日,往前7天;否则往前到上一个周日
const lastSunday = new Date(
today.getTime() + daysToLastSunday * 24 * 60 * 60 * 1000,
)
const endTime = lastSunday
.toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
.replace(/\//g, '-')
return `当前周期(${startTime}${endTime})暂无订单数据\n\n请在订单流转后等待数据更新查看趋势`
} else if (timeRange === '2') {
return `当前周期(${lastMonth}${today})暂无订单数据\n\n请在订单流转后等待数据更新查看趋势`
// 六个月前该月第一天的日期
const now = new Date()
const sixMonthsAgo = new Date(now.getFullYear(), now.getMonth() - 6, 1)
const startTime = sixMonthsAgo
.toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
.replace(/\//g, '-')
// 上一月第一天的日期
const currentDate = new Date()
const lastMonthFirstDay = new Date(
currentDate.getFullYear(),
currentDate.getMonth() - 1,
1,
)
const endTime = lastMonthFirstDay
.toLocaleDateString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})
.replace(/\//g, '-')
return `当前周期(${startTime}${endTime})暂无订单数据\n\n请在订单流转后等待数据更新查看趋势`
}
return ''
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment