fix: 传参最近3个月内(90天)
parent
604549b6a5
commit
89f7726b45
|
@ -1,9 +1,33 @@
|
|||
import axios from 'axios'
|
||||
// 获取今天以及 90 天之前的日期,以 2024-06-01 的格式返回
|
||||
|
||||
function getDatesFormatted() {
|
||||
// 获取今天的日期
|
||||
const today = new Date()
|
||||
|
||||
// 获取90天前的日期
|
||||
const ninetyDaysAgo = new Date(today)
|
||||
ninetyDaysAgo.setDate(today.getDate() - 90)
|
||||
|
||||
// 格式化日期函数
|
||||
function formatDate(date) {
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
// 返回格式化后的日期
|
||||
return {
|
||||
today: formatDate(today),
|
||||
ninetyDaysAgo: formatDate(ninetyDaysAgo)
|
||||
}
|
||||
}
|
||||
|
||||
// 单位机时统计
|
||||
export const getDepartDuration = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findTopByOrg?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.post(`/screen_server/hpc/findTopByOrg?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
|
@ -14,7 +38,7 @@ export const getDepartDuration = () =>
|
|||
// 软件机时统计
|
||||
export const getSoftwareDuration = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findTopBySoft?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.post(`/screen_server/hpc/findTopBySoft?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
|
@ -25,7 +49,7 @@ export const getSoftwareDuration = () =>
|
|||
// 当前在用软件
|
||||
export const getInUseSoftware = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findTopSoftList?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.post(`/screen_server/hpc/findTopSoftList?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
|
@ -36,7 +60,7 @@ export const getInUseSoftware = () =>
|
|||
// 用户机时用量
|
||||
export const getUserUseTrend = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findTopByUser?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.post(`/screen_server/hpc/findTopByUser?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
|
@ -46,7 +70,7 @@ export const getUserUseTrend = () =>
|
|||
// 软件集成数量
|
||||
export const getSoftwareIntegrate = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findSoftCount?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.post(`/screen_server/hpc/findSoftCount?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue