| | |
| | | this.queryParams.vehicleNo = query.vehicleNo; |
| | | } |
| | | |
| | | // 设置时间范围 |
| | | // 设置默认时间范围 |
| | | 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() { |
| | |
| | | /** 查询GPS列表 */ |
| | | getList() { |
| | | this.loading = true; |
| | | listGps(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]; |
| | | } |
| | | |
| | | listGps(params).then(response => { |
| | | this.gpsList = response.rows; |
| | | this.total = response.total; |
| | | this.loading = false; |
| | |
| | | this.drawTrack(); |
| | | } |
| | | }); |
| | | }, |
| | | /** 格式化时间 */ |
| | | 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}`; |
| | | }, |
| | | async translatePoints(points) { |
| | | // 将WGS84坐标转换为百度坐标 |
| | |
| | | }, |
| | | /** 重置按钮操作 */ |
| | | 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(); |
| | | }, |