From 783686ff99c571dd41fc86cc7d93c92173fe86a0 Mon Sep 17 00:00:00 2001 From: wanglizhong <wlz> Date: 星期四, 08 五月 2025 10:30:09 +0800 Subject: [PATCH] fix:电子地图显示问题 --- ruoyi-ui/src/views/system/gps/map.vue | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-) diff --git a/ruoyi-ui/src/views/system/gps/map.vue b/ruoyi-ui/src/views/system/gps/map.vue index a9ee044..bd09c70 100644 --- a/ruoyi-ui/src/views/system/gps/map.vue +++ b/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(); }, @@ -398,7 +437,7 @@ marker.addEventListener("click", () => { // 鍒涘缓淇℃伅绐楀彛 const infoWindow = new BMap.InfoWindow( - `鏃堕棿锛�${currentSegment[index].collectTime}<br/>閫熷害锛�${ + `杞︾墝鍙凤細${currentSegment[index].vehicleNo}<br/>鏃堕棿锛�${currentSegment[index].collectTime}<br/>閫熷害锛�${ currentSegment[index].speed }km/h<br/>鏂瑰悜锛�${currentSegment[index].direction}掳<br/>鍦板潃锛�${address}` ); @@ -482,7 +521,7 @@ marker.addEventListener("click", () => { // 鍒涘缓淇℃伅绐楀彛 const infoWindow = new BMap.InfoWindow( - `鏃堕棿锛�${row.collectTime}<br/>閫熷害锛�${row.speed}km/h<br/>鏂瑰悜锛�${row.direction}掳<br/>鍦板潃锛�${address}` + `杞︾墝鍙凤細${row.vehicleNo}<br/>鏃堕棿锛�${row.collectTime}<br/>閫熷害锛�${row.speed}km/h<br/>鏂瑰悜锛�${row.direction}掳<br/>鍦板潃锛�${address}` ); this.map.openInfoWindow(infoWindow, data.points[0]); }); -- Gitblit v1.9.1