From d8743368ffda9bc0fb2c6818f695a9a6b1079e57 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期五, 19 九月 2025 18:22:15 +0800
Subject: [PATCH] laster

---
 pages/map/index.vue |  242 ++++++++++++++++++++++++++----------------------
 1 files changed, 130 insertions(+), 112 deletions(-)

diff --git a/pages/map/index.vue b/pages/map/index.vue
index 98e8b78..e176d03 100644
--- a/pages/map/index.vue
+++ b/pages/map/index.vue
@@ -393,6 +393,8 @@
 		showToast,
 		showModal,
 		session,
+		showError,
+		showInfo
 	} from "@/comm/utils.js"
 	// import OIFabric from "@/components/oi-fabric/index.vue"
 	import {
@@ -480,6 +482,7 @@
 					img_x: 1,
 					img_y: 1
 				},
+				positioningAgv: false
 			}
 		},
 		computed: {
@@ -575,7 +578,7 @@
 					this.setData({
 						unlinked: true
 					})
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 
@@ -719,11 +722,12 @@
 
 						showModal("宸茶褰曠殑璺緞灏嗕細琚垹闄ゃ�", "鏄惁瑕侀�鍑虹ず鏁欙紵").then(async (res) => {
 							if (res) {
-								if (mapOperationStatus == 'end' || mapOperationStatus == 'save') {
+								if (this.mapOperationStatus == 'end' || this.mapOperationStatus ==
+									'save') {
 									try {
-										await delTeachingMode(this.vehicleIp, [_this.teachingModeCur])
+										await delTeachingMode(this.vehicleIp, [this.teachingModeCur])
 									} catch (ex) {
-										this.showError(ex)
+										showError(ex)
 									}
 
 								}
@@ -806,7 +810,7 @@
 					const info = await getAgvState(this.vehicleIp)
 					return info
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 					return {}
 				}
 			},
@@ -815,7 +819,7 @@
 					const paths = await getCurrentTeachingData(this.vehicleIp) || []
 					return paths
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 					return []
 				}
 			},
@@ -825,7 +829,7 @@
 					const info = await stations(this.vehicleIp)
 					return info.station_list || []
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 					return []
 				}
 			},
@@ -834,7 +838,7 @@
 					const info = await getMapUrl(this.vehicleIp, id)
 					return info
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 					return {}
 				}
 			},
@@ -864,20 +868,21 @@
 				try {
 					this.setData({
 						bgProgressPercent: 0,
+						bgLoading: true
 					})
 					const infoAgv = await this.loadAgvState()
 					const stationLst = await this.loadStations()
 
 					const infoMap = await this.loadMapInfo(id)
 					this.curMapInfo = {
-						proportion: infoMap.proportion || 1,
-						img_proportion: infoMap.img_proportion || 1,
-						max_x: infoMap.max_x || 1,
-						max_y: infoMap.max_y || 1,
-						min_x: infoMap.min_x || 0,
-						min_y: infoMap.min_y || 0,
-						img_x: infoMap.img_x || 1,
-						img_y: infoMap.img_y || 1
+						proportion: parseInt(infoMap.proportion) || 1,
+						img_proportion: parseInt(infoMap.img_proportion) || 1,
+						max_x: parseInt(infoMap.max_x) || 1,
+						max_y: parseInt(infoMap.max_y) || 1,
+						min_x: parseInt(infoMap.min_x) || 0,
+						min_y: parseInt(infoMap.min_y) || 0,
+						img_x: parseInt(infoMap.img_x) || 1,
+						img_y: parseInt(infoMap.img_y) || 1
 					}
 					// getApp().globalData.curScene = infoMap
 					this.setData({
@@ -914,20 +919,21 @@
 
 						},
 						{
-							method: "move_canvas",
+							method: "move_pt_center",
 							param: {
 								x: infoAgv.x,
 								y: infoAgv.y
 							}
 						}
 					])
+					this.positioningAgv = true
 					this.mapShowAgv = true
 				} catch (ex) {
 					this.setData({
 						bgProgressPercent: 0,
 						bgLoading: false
 					})
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 
@@ -1086,7 +1092,14 @@
 					}
 
 					this.$refs.refPopupOperateTeaching.open("bottom")
+				} else if (param.method == "cancel_positioning_agv") {
+					this.positioningAgv = false
+				} else if (param.method == "show_log") {
+					const listLog = session.getValue("request_log") || []
+					listLog.unshift(param.data)
+					session.setValue("request_log", listLog)
 				}
+
 
 			},
 			clickMapStation() {
@@ -1138,11 +1151,9 @@
 					mode: "Public",
 					main_road: 1,
 				}
+				this.positioningAgv = true
 				this.mapOperationType = "public_teaching"
 				this.ctxDataStr = JSON.stringify([{
-					method: "set_selectable",
-					param: false,
-				}, {
 					method: "public_teaching",
 				}])
 
@@ -1190,7 +1201,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					uni.hideLoading()
 				}
@@ -1208,7 +1219,7 @@
 							if (this.sceneList.length > 0)
 								this.changeMap(this.sceneList[0])
 						} catch (ex) {
-							this.showError(ex)
+							showError(ex)
 						} finally {
 							uni.hideLoading()
 						}
@@ -1263,7 +1274,7 @@
 								param: [this.regionEdit]
 							},
 							{
-								method: "move_canvas",
+								method: "move_pt_center",
 								param: {
 									x: agv.x,
 									y: agv.y
@@ -1272,7 +1283,7 @@
 						])
 					}
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			async clickPlanProhibitionRegion() {
@@ -1309,7 +1320,7 @@
 								param: [this.regionEdit]
 							},
 							{
-								method: "move_canvas",
+								method: "move_pt_center",
 								param: {
 									x: agv.x,
 									y: agv.y
@@ -1318,7 +1329,7 @@
 						])
 					}
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 
@@ -1350,7 +1361,7 @@
 							param: [this.wallEdit]
 						},
 						{
-							method: "move_canvas",
+							method: "move_pt_center",
 							param: {
 								x: agv.x,
 								y: agv.y
@@ -1358,7 +1369,7 @@
 						}
 					])
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 
 			},
@@ -1387,7 +1398,7 @@
 					showToast("鍦烘櫙閲嶅懡鍚嶆垚鍔燂紒")
 				} catch (ex) {
 					this.mapOperationType = "edit_scene_name"
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					uni.hideLoading()
 					this.loading = false
@@ -1416,12 +1427,13 @@
 				this.mapOperationType = ""
 			},
 			clickStationDelete() {
-				const _this = this
-				showModal("璇ョ珯鐐瑰凡缁戝畾浠诲姟锛屽垹闄ょ珯鐐瑰悗缁戝畾鐨勪换鍔′細鍋滄骞跺垹闄�, "鏄惁纭鍒犻櫎锛�).then((res) => {
-					if (res) {
-						this.stationDelete(this.stationEdit)
-					}
-				})
+				this.stationDelete(this.stationEdit)
+				// const _this = this
+				// showModal("璇ョ珯鐐瑰凡缁戝畾浠诲姟锛屽垹闄ょ珯鐐瑰悗缁戝畾鐨勪换鍔′細鍋滄骞跺垹闄�, "鏄惁纭鍒犻櫎锛�).then((res) => {
+				// 	if (res) {
+
+				// 	}
+				// })
 			},
 			async stationAdd(item) {
 				try {
@@ -1440,7 +1452,7 @@
 
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					uni.hideLoading()
 				}
@@ -1463,7 +1475,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					uni.hideLoading()
 				}
@@ -1477,6 +1489,7 @@
 						this.stationAdd(this.stationEdit)
 						this.mapOperationType = "public_teaching"
 						this.mapOperationStatus = "teaching"
+						this.positioningAgv = true
 						return
 					} else if (this.mapOperationType == "edit_station") {
 						this.stationUpdate(this.stationEdit)
@@ -1487,7 +1500,7 @@
 					}])
 					this.mapOperationType = ''
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			async stationDelete(item) {
@@ -1514,7 +1527,7 @@
 					}])
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					uni.hideLoading()
 				}
@@ -1559,14 +1572,14 @@
 			},
 			async clickStationNameOK() {
 				try {
-					this.loading = true
+
 					const name = this.stationEdit.name.trim()
 					if (!name) {
 						showToast("绔欑偣鍚嶇О杩樻湭杈撳叆")
 						return
 					}
-					if (this.mapOperationType == 'add_station' || this
-						.mapOperationType == "teaching_add_station") {
+					this.loading = true
+					if (this.mapOperationType == 'add_station' || this.mapOperationType == "teaching_add_station") {
 						const agv = await this.loadAgvState()
 						this.stationEdit = {
 							stationID: this.getMaxStationNo + 1,
@@ -1589,7 +1602,7 @@
 							method: "edit_station_pos",
 							param: this.stationEdit
 						}, {
-							method: "move_canvas",
+							method: "move_pt_center",
 							param: {
 								x: agv.x,
 								y: agv.y
@@ -1613,7 +1626,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					this.loading = false
 				}
@@ -1639,7 +1652,7 @@
 					method: "update_station",
 					param: [this.stationEdit]
 				}, {
-					method: "move_canvas",
+					method: "move_pt_center",
 					param: {
 						x: this.stationEdit.x,
 						y: this.stationEdit.y
@@ -1654,7 +1667,7 @@
 					method: "update_station",
 					param: [this.stationEdit]
 				}, {
-					method: "move_canvas",
+					method: "move_pt_center",
 					param: {
 						x: this.stationEdit.x,
 						y: this.stationEdit.y
@@ -1667,7 +1680,7 @@
 					method: "update_station",
 					param: [this.stationEdit]
 				}, {
-					method: "move_canvas",
+					method: "move_pt_center",
 					param: {
 						x: this.stationEdit.x,
 						y: this.stationEdit.y
@@ -1680,7 +1693,7 @@
 					method: "update_station",
 					param: [this.stationEdit]
 				}, {
-					method: "move_canvas",
+					method: "move_pt_center",
 					param: {
 						x: this.stationEdit.x,
 						y: this.stationEdit.y
@@ -1766,19 +1779,20 @@
 
 			async clickVehiclePosition() {
 				try {
+					this.positioningAgv = true
 					const infoAgv = await this.loadAgvState()
 					this.ctxDataStr = JSON.stringify([{
 						method: "update_agv_state",
 						param: infoAgv
 					}, {
-						method: "move_canvas",
+						method: "move_pt_center",
 						param: {
 							x: infoAgv.x,
 							y: infoAgv.y
 						}
 					}])
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			async clickPositionStation() {
@@ -1801,7 +1815,7 @@
 							param: [this.stationEdit]
 						},
 						{
-							method: "move_canvas",
+							method: "move_pt_center",
 							param: {
 								x: infoAgv.x,
 								y: infoAgv.y
@@ -1811,7 +1825,7 @@
 
 					])
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			async loadTeachingMode() {
@@ -1825,7 +1839,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 					return {
 						Public: [],
 						Stations: []
@@ -1836,6 +1850,9 @@
 				try {
 					this.teachingMode = await this.loadTeachingMode()
 					this.ctxDataStr = JSON.stringify([{
+							method: "clear_teaching_path",
+						},
+						{
 							method: "public_teaching_path",
 							param: this.teachingMode.Public || []
 						},
@@ -1851,7 +1868,7 @@
 					])
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 
 				}
 			},
@@ -1893,14 +1910,13 @@
 						}
 					])
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			async refreshAgvPosition() {
 				try {
 					if (this.isPageVisible && this.mapShowAgv) {
 						const agv = await this.loadAgvState()
-
 						const listCtrData = [{
 							method: "update_agv_state",
 							param: agv
@@ -1917,13 +1933,28 @@
 								}
 							})
 						}
+						if (this.positioningAgv) {
+							listCtrData.push({
+								method: "move_pt_visible",
+								param: {
+									x: agv.x,
+									y: agv.y,
+									width:80,
+									height:80,
+								}
+							})
+
+						}
 						this.ctxDataStr = JSON.stringify(listCtrData)
 					}
+					setTimeout(this.refreshAgvPosition, 1000);
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex).then((res) => {
+						setTimeout(this.refreshAgvPosition, 1000);
+					})
 				} finally {
 					// 鏃犺鎴愬姛澶辫触锛� 绉掑悗鍐嶆潵
-					setTimeout(this.refreshAgvPosition, 1000);
+
 				}
 
 			},
@@ -1946,12 +1977,11 @@
 					uni.showLoading({
 						title: "绀烘暀缁撴潫"
 					})
-					await teachingModeFlag(this.vehicleIp,
-						teachingMode)
+					await teachingModeFlag(this.vehicleIp, teachingMode)
 
 					this.mapOperationStatus = "end"
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					uni.hideLoading()
 				}
@@ -1969,7 +1999,7 @@
 					await _this.teachingStart("Public")
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					this.loading = false
 					uni.hideLoading()
@@ -1996,7 +2026,7 @@
 								_this.mapOperationStatus = ""
 
 							} catch (ex) {
-								this.showError(ex)
+								showError(ex)
 							} finally {
 								this.loading = false
 							}
@@ -2013,7 +2043,7 @@
 
 				this.mapOperationStatus = "save"
 				try {} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 
 			},
@@ -2071,7 +2101,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 
 			},
@@ -2094,41 +2124,27 @@
 						.teachingModeCur
 					)
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				} finally {
 					this.loading = false
 				}
 
 			},
-			async onTeachingModeMainRoad(
-				val) {
+			async onTeachingModeMainRoad(val) {
 				try {
-					if (this
-						.mapOperationStatus
-					) {
+					if (this.mapOperationStatus) {
 
-						if (this
-							.teachingModeCur
-							.main_road ==
-							val) {
+						if (this.teachingModeCur.main_road == val) {
 							return
 						}
-						this.teachingModeCur
-							.main_road =
-							val
-						this.teachingModeCur
-							.teaching_flag =
-							1
-						this.teachingModeCur
-							.mode =
-							"Public"
-						const res =
-							await teachingModeFlag(
-								this
-								.vehicleIp,
-								this
-								.teachingModeCur
-							)
+						this.teachingModeCur.teaching_flag = 0
+						const oldName = this.teachingModeCur.name
+						await teachingModeFlag(this.vehicleIp, this.teachingModeCur)
+						this.teachingModeCur.main_road = val
+						this.teachingModeCur.teaching_flag = 1
+						this.teachingModeCur.mode = "Public"
+						this.teachingModeCur.name = ""
+						const res = await teachingModeFlag(this.vehicleIp, this.teachingModeCur)
 						if (val == 0)
 							showToast(
 								"宸插皢璇ヨ矾娈佃矾寰勪繚瀛樹负涓昏矾绀烘暀璺嚎"
@@ -2138,10 +2154,25 @@
 								"宸插皢璇ヨ矾娈佃矾寰勪繚瀛樹负鏀矾绀烘暀璺嚎"
 							)
 						if (res?.name)
-							this
-							.teachingModeCur
-							.name = res
-							.name
+							this.teachingModeCur.name = res.name
+							
+							const {
+								data
+							} = await getTeachingMode(this.vehicleIp)
+								
+							const publicList = data.Public || []
+							const curIndex = publicList.findIndex((a)=>a.name == oldName)
+							
+							if(curIndex > -1)
+							{
+								this.ctxDataStr = JSON.stringify([{
+									method: "public_teaching_path",
+									param: [publicList[curIndex]]
+								} ])
+								
+							}
+							
+							
 					} else {
 						this.teachingModeCur
 							.main_road =
@@ -2149,7 +2180,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			clickTeachingDelete() {
@@ -2188,7 +2219,7 @@
 								param: item,
 							}])
 				} catch (ex) {
-					this.showError(
+					showError(
 						ex)
 				} finally {
 					uni.hideLoading()
@@ -2202,24 +2233,11 @@
 					await delTeachingModeData(this.vehicleIp, data)
 					this.reloadTeachingMode()
 				} catch (ex) {
-					this.showError(
-						ex)
+					showError(ex)
 				} finally {
 					uni.hideLoading()
 				}
 			},
-
-			showError(ex) {
-				let exStr = JSON.stringify(ex)
-				if (exStr == "{}")
-					exStr = ex
-				let tip = typeof ex.msg == "string" ? ex.msg : typeof ex.errMsg == "string" ? ex.errMsg : exStr
-				showModal(tip,
-					"閿欒",
-					false,
-					"纭畾")
-			},
-
 
 		}
 	}

--
Gitblit v1.9.1