wanglizhong
2025-05-08 783686ff99c571dd41fc86cc7d93c92173fe86a0
ruoyi-ui/src/views/system/gps/map.vue
@@ -169,10 +169,18 @@
    if (query.timestamp) {
      this.queryParams.timestamp = query.timestamp;
    }
    // 设置时间范围
    // 设置默认时间范围
    const today = new Date();
    const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
    const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
    this.dateRange = [this.parseTime(startTime), this.parseTime(endTime)];
    // 如果URL中有时间参数,则使用URL中的时间
    if (query.beginTime && query.endTime) {
      this.dateRange = [query.beginTime, query.endTime];
    }
    this.getList();
  },
  mounted() {
@@ -220,10 +228,37 @@
        };
      });
    },
    /** 格式化时间 */
    parseTime(time) {
      const year = time.getFullYear();
      const month = String(time.getMonth() + 1).padStart(2, '0');
      const day = String(time.getDate()).padStart(2, '0');
      const hours = String(time.getHours()).padStart(2, '0');
      const minutes = String(time.getMinutes()).padStart(2, '0');
      const seconds = String(time.getSeconds()).padStart(2, '0');
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
    /** 查询GPS列表 */
    getList() {
      this.loading = true;      
      anonymousList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
      // 构建查询参数
      const params = {
        ...this.queryParams
      };
      // 如果没有选择时间范围,则默认使用当天
      if (!this.dateRange || this.dateRange.length === 0) {
        const today = new Date();
        const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
        const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
        params.beginTime = this.parseTime(startTime);
        params.endTime = this.parseTime(endTime);
      } else {
        params.beginTime = this.dateRange[0];
        params.endTime = this.dateRange[1];
      }
      anonymousList(params).then(response => {
        this.gpsList = response.rows;
        this.total = response.total;
        this.loading = false;
@@ -252,7 +287,11 @@
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      // 重置为当天时间范围
      const today = new Date();
      const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
      const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
      this.dateRange = [this.parseTime(startTime), this.parseTime(endTime)];
      this.resetForm("queryForm");
      this.handleQuery();
    },