|
|
@ -188,6 +188,7 @@ import API from '@/util/http' |
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import utc from 'dayjs-plugin-utc' |
|
|
|
import weekday from 'dayjs/plugin/weekday' |
|
|
|
dayjs.extend(utc) |
|
|
|
import { ArrowUpBold, ArrowDownBold, SemiSelect } from '@element-plus/icons-vue' |
|
|
|
import { marketMapping } from "@/utils/marketMap.js"; |
|
|
@ -306,16 +307,25 @@ const getToday = function () { |
|
|
|
} |
|
|
|
// 本周 |
|
|
|
const getWeek = function () { |
|
|
|
const today = dayjs() |
|
|
|
const startTime = ((today.startOf('week').add(1, 'day')).format('YYYY-MM-DD HH:mm:ss')) |
|
|
|
const endTime = (today.endOf('week').add(1, 'day')).format('YYYY-MM-DD HH:mm:ss') |
|
|
|
// const endTime = today.add(1, 'week').startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss') |
|
|
|
dateRange.value = [startTime, endTime] |
|
|
|
console.log('看看dateRange', dateRange.value) |
|
|
|
activeTimeRange.value = 'week' // 标记当前激活状态 |
|
|
|
const today = dayjs(); |
|
|
|
// 获取今天是星期几(0是周日,1是周一,...,6是周六) |
|
|
|
const day = today.day(); |
|
|
|
|
|
|
|
getChartData() |
|
|
|
} |
|
|
|
// 计算本周一(如果今天是周一,就取今天;如果是周日,就减6天) |
|
|
|
let monday = today.subtract(day === 0 ? 6 : day - 1, 'day'); |
|
|
|
// 计算本周日(如果今天是周日,就取今天;否则就加(7 - day)天) |
|
|
|
let sunday = today.add(day === 0 ? 0 : 7 - day, 'day'); |
|
|
|
|
|
|
|
// 设置时间为起始和结束 |
|
|
|
const startTime = monday.startOf('day').format('YYYY-MM-DD HH:mm:ss'); |
|
|
|
const endTime = sunday.endOf('day').format('YYYY-MM-DD HH:mm:ss'); |
|
|
|
|
|
|
|
dateRange.value = [startTime, endTime]; |
|
|
|
console.log('本周时间范围(周一到周日):', dateRange.value); |
|
|
|
activeTimeRange.value = 'week'; |
|
|
|
|
|
|
|
getChartData(); |
|
|
|
}; |
|
|
|
// 本月 |
|
|
|
const getMonth = function () { |
|
|
|
const today = dayjs() |
|
|
|