zhoushihao
2 天以前 4e3b8155722b66e25df3c6fd42cc586b68dea391
UI-Project/src/views/Caching/cachingbeforehistory.vue
@@ -26,10 +26,15 @@
                :value="item.value"
              />
          </el-select>
            <el-date-picker v-model="timeRange" type="datetimerange" range-separator="至" :start-placeholder="$t('reportmanage.starttime')"
             style="margin-left: 15px;" value-format = "YYYY-MM-DD hh:mm:ss"
              :end-placeholder="$t('reportmanage.endtime')">
            </el-date-picker>
          <el-date-picker
            style="margin-left: 15px;"
             v-model="timeRange"
             type="datetimerange"
             :shortcuts="shortcuts"
             range-separator="至"
             :start-placeholder="$t('reportmanage.starttime')"
             :end-placeholder="$t('reportmanage.endtime')"
           />
          <el-button type="primary" style="margin-left: 10px;margin-bottom: 10px;" @click="handleClick()">{{$t('reportmanage.inquire')}}</el-button>
     </div>
     <div style="margin-bottom: 10px;margin-top: 20px;margin-left: 20px;">
@@ -147,7 +152,6 @@
    }
}
catch (error) {
    console.error(error);
  }
}
const Daily = async () => {
@@ -171,7 +175,6 @@
    }
}
catch (error) {
    console.error(error);
  }
}
const handlePageChange2 = (newPage) => {
@@ -191,8 +194,8 @@
        glassId: glassId.value,
        taskState: taskState.value,
        taskType: taskType.value,
        startTime: (timeRange.value && timeRange.value[0]) || '',
        endTime: (timeRange.value && timeRange.value[1]) || '',
        beginDate: (formatTimestamp(timeRange.value) && formatTimestamp(timeRange.value[0])) || '',
        endDate: (formatTimestamp(timeRange.value) && formatTimestamp(timeRange.value[1])) || '',
    })
      if (response.code == 200) {
        ElMessage.success(response.message);
@@ -203,7 +206,6 @@
    }
}
catch (error) {
    console.error(error);
  }
}
const Dailya = async (page) => {
@@ -217,8 +219,8 @@
        glassId: glassId.value,
        taskState: taskState.value,
        taskType: taskType.value,
        startTime: (timeRange.value && timeRange.value[0]) || '',
        endTime: (timeRange.value && timeRange.value[1]) || '',
        beginDate: (formatTimestamp(timeRange.value) && formatTimestamp(timeRange.value[0])) || '',
        endDate: (formatTimestamp(timeRange.value) && formatTimestamp(timeRange.value[1])) || '',
    })
      if (response.code == 200) {
        countOutOne.value = response.data.countOutOne
@@ -228,7 +230,6 @@
    }
}
catch (error) {
    console.error(error);
  }
}
const handleClick = async () => {
@@ -247,8 +248,8 @@
        glassId: glassId.value,
        taskState: taskState.value,
        taskType: taskType.value,
      startTime: (timeRange.value && timeRange.value[0]) || '',
      endTime: (timeRange.value && timeRange.value[1]) || '',
        beginDate: (formatTimestamp(timeRange.value) && formatTimestamp(timeRange.value[0])) || '',
        endDate: (formatTimestamp(timeRange.value) && formatTimestamp(timeRange.value[1])) || '',
    })
      if (response.code == 200) {
        currentPage2.value = 1;
@@ -260,7 +261,6 @@
    }
}
catch (error) {
    console.error(error);
  }
}
const Dailyhistorical = async () => {
@@ -274,8 +274,8 @@
        glassId: glassId.value,
        taskState: taskState.value,
        taskType: taskType.value,
        startTime: (timeRange.value && timeRange.value[0]) || '',
        endTime: (timeRange.value && timeRange.value[1]) || '',
        beginDate: (formatTimestamp(timeRange.value) && formatTimestamp(timeRange.value[0])) || '',
        endDate: (formatTimestamp(timeRange.value) && formatTimestamp(timeRange.value[1])) || '',
    })
      if (response.code == 200) {
        countOutOne.value = response.data.countOutOne
@@ -285,7 +285,6 @@
    }
}
catch (error) {
    console.error(error);
  }
}
// 格式化时间戳为年月日时间字符串的函数
@@ -299,6 +298,41 @@
  const seconds = String(date.getSeconds()).padStart(2, '0'); // 补零(如果需要显示时间)
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
const shortcuts = [
  {
    text: '最近一周',
    value: () => {
      const backendTime = new Date(getglobalDate)
      const oneWeekAgo = new Date(getglobalDate)
      oneWeekAgo.setHours(0, 0, 0, 0);
      oneWeekAgo.setDate(oneWeekAgo.getDate() - 7)
      timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)]
      window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo))
    },
  },
  {
    text: '最近一个月',
    value: () => {
      const backendTime = new Date(getglobalDate)
      const oneWeekAgo = new Date(getglobalDate)
      oneWeekAgo.setHours(0, 0, 0, 0);
      oneWeekAgo.setMonth(oneWeekAgo.getMonth() - 1)
      timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)]
      window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo))
    },
  },
  {
    text: '最近三个月',
    value: () => {
      const backendTime = new Date(getglobalDate)
      const oneWeekAgo = new Date(getglobalDate)
      oneWeekAgo.setHours(0, 0, 0, 0);
      oneWeekAgo.setMonth(oneWeekAgo.getMonth() - 3)
      timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)]
      window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo))
},
  },
]
// 格式化后端时间并计算一周前的时间
const defaultTime = ref<[Date, Date]>([new Date(), new Date()]);
function parseAndSetTime() {