|
@@ -367,7 +367,31 @@ const formatDate = (date): string => {
|
|
|
const initMyoption = async () => {
|
|
const initMyoption = async () => {
|
|
|
// 只在初始化时设置默认值,不覆盖已有值
|
|
// 只在初始化时设置默认值,不覆盖已有值
|
|
|
if (!completeRateParams.createTime || completeRateParams.createTime.length === 0) {
|
|
if (!completeRateParams.createTime || completeRateParams.createTime.length === 0) {
|
|
|
- completeRateParams.createTime = [formatDate(start), formatDate(end)]
|
|
|
|
|
|
|
+ const start = new Date()
|
|
|
|
|
+ start.setTime(start.getTime() - 7 * 24 * 60 * 60 * 1000) // 近一周
|
|
|
|
|
+
|
|
|
|
|
+ const end = new Date()
|
|
|
|
|
+
|
|
|
|
|
+ // 将开始时间设置为当天的 00:00:00
|
|
|
|
|
+ const startTime = new Date(start)
|
|
|
|
|
+ startTime.setHours(0, 0, 0, 0)
|
|
|
|
|
+
|
|
|
|
|
+ // 将结束时间设置为当天的 23:59:59
|
|
|
|
|
+ const endTime = new Date(end)
|
|
|
|
|
+ endTime.setHours(23, 59, 59, 999)
|
|
|
|
|
+
|
|
|
|
|
+ // 格式化为 YYYY-MM-DD HH:mm:ss
|
|
|
|
|
+ const formatDate = (date) => {
|
|
|
|
|
+ const year = date.getFullYear()
|
|
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
+ const day = String(date.getDate()).padStart(2, '0')
|
|
|
|
|
+ const hours = String(date.getHours()).padStart(2, '0')
|
|
|
|
|
+ const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
|
|
|
+ const seconds = String(date.getSeconds()).padStart(2, '0')
|
|
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ completeRateParams.createTime = [formatDate(startTime), formatDate(endTime)]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const res = await IotStatApi.getCompleteRate(completeRateParams)
|
|
const res = await IotStatApi.getCompleteRate(completeRateParams)
|
|
@@ -386,8 +410,30 @@ const initMyoption = async () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleDateChange = (val) => {
|
|
const handleDateChange = (val) => {
|
|
|
- console.log('handleDateChange', val)
|
|
|
|
|
- completeRateParams.createTime = [val[0], val[1]]
|
|
|
|
|
|
|
+ if (!val || val.length !== 2) return
|
|
|
|
|
+
|
|
|
|
|
+ const [start, end] = val
|
|
|
|
|
+
|
|
|
|
|
+ // 将开始时间设置为当天的 00:00:00
|
|
|
|
|
+ const startTime = new Date(start)
|
|
|
|
|
+ startTime.setHours(0, 0, 0, 0)
|
|
|
|
|
+
|
|
|
|
|
+ // 将结束时间设置为当天的 23:59:59
|
|
|
|
|
+ const endTime = new Date(end)
|
|
|
|
|
+ endTime.setHours(23, 59, 59, 999)
|
|
|
|
|
+
|
|
|
|
|
+ // 格式化为 YYYY-MM-DD HH:mm:ss
|
|
|
|
|
+ const formatDate = (date) => {
|
|
|
|
|
+ const year = date.getFullYear()
|
|
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
+ const day = String(date.getDate()).padStart(2, '0')
|
|
|
|
|
+ const hours = String(date.getHours()).padStart(2, '0')
|
|
|
|
|
+ const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
|
|
|
+ const seconds = String(date.getSeconds()).padStart(2, '0')
|
|
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ completeRateParams.createTime = [formatDate(startTime), formatDate(endTime)]
|
|
|
initMyoption()
|
|
initMyoption()
|
|
|
}
|
|
}
|
|
|
|
|
|