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/teaching/index.vue |   78 ++++++++++++++++++++------------------
 1 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/pages/teaching/index.vue b/pages/teaching/index.vue
index 2b171f9..d412b91 100644
--- a/pages/teaching/index.vue
+++ b/pages/teaching/index.vue
@@ -150,7 +150,9 @@
 <script>
 	import {
 		showToast,
-		showModal
+		showModal,
+		showError,
+		showInfo
 	} from "@/comm/utils.js"
 	import {
 		Button
@@ -284,7 +286,7 @@
 
 				} catch (ex) {
 
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			async loadAgvState() {
@@ -292,7 +294,7 @@
 					const info = await getAgvState(this.ip)
 					return info
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 					return {}
 				}
 			},
@@ -301,7 +303,7 @@
 					const info = await stations(this.ip)
 					return info.station_list || []
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 					return []
 				}
 			},
@@ -367,7 +369,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 
 			},
@@ -379,21 +381,14 @@
 							this.calibratioStationType = "end"
 							this.$refs.refPopupCalibration.open()
 						} else {
-							this.teachingModeCur.teaching_flag = 0
-							await teachingModeFlag(this.ip, this.teachingModeCur)
-							this.teachingMode = await getTeachingMode(this.ip)
-
-							this.teachingStatus = "end"
+							this.askTeachingBiDirection(this.teachingModeCur)
 
 						}
 					} else {
-						this.teachingModeCur.teaching_flag = 0
-						await teachingModeFlag(this.ip, this.teachingModeCur)
-						this.teachingMode = await getTeachingMode(this.ip)
-						this.teachingStatus = "end"
+						this.askTeachingBiDirection(this.teachingModeCur)
 					}
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 
 			},
@@ -412,7 +407,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			async clickTeachingStart() {
@@ -440,7 +435,7 @@
 										stationTeaching.splice(curIndex, 1)
 										_this.teachingStart("Stations")
 									} catch (ex) {
-										this.showError(ex)
+										showError(ex)
 									}
 
 								} else {
@@ -459,7 +454,7 @@
 					}
 
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			clickTeachingEnd() {
@@ -480,7 +475,7 @@
 							_this.teachingMode = await getTeachingMode(_this.ip)
 
 						} catch (ex) {
-							this.showError(ex)
+							showError(ex)
 						}
 					} else {
 						_this.teachingStatus = "save"
@@ -492,7 +487,7 @@
 
 				this.teachingStatus = "save"
 				try {} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 
 			},
@@ -639,14 +634,12 @@
 							list[curIndex].y = infoAgv.y
 
 						}
-						this.teachingStatus = "end"
-						this.teachingModeCur.teaching_flag = 0
-						await teachingModeFlag(this.ip, this.teachingModeCur)
-						this.teachingMode = await getTeachingMode(this.ip)
+						this.askTeachingBiDirection(this.teachingModeCur)
+
 
 					}
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
 				}
 			},
 			async clickNoCalibration() {
@@ -667,27 +660,38 @@
 
 					} else if (this.calibratioStationType == "end") {
 
-						this.teachingModeCur.teaching_flag = 0
-						await teachingModeFlag(this.ip, this.teachingModeCur)
-						this.teachingMode = await getTeachingMode(this.ip)
+						this.askTeachingBiDirection(this.teachingModeCur)
 
 					}
 				} catch (ex) {
-					this.showError(ex)
+					showError(ex)
+				}
+			},
+			askTeachingBiDirection(teachingMode) {
+				showModal("鏄惁灏嗗綋鍓嶇ず鏁欒矾绾胯缃负鍙屽悜?", "绀烘暀缁撴潫").then((res) => {
+					if (res) {
+						teachingMode.bidirection = "1"
+					} else {
+						teachingMode.bidirection = "0"
+					}
+					teachingMode.teaching_flag = 0
+					this.finishTeaching(teachingMode)
+				})
+
+			},
+			async finishTeaching(teachingMode) {
+				try {
+					await teachingModeFlag(this.ip, teachingMode)
+					this.teachingMode = await getTeachingMode(this.ip)
+					this.teachingStatus = "end"
+				} catch (ex) {
+					showError(ex)
 				}
 			},
 			clickBackTeaching() {
 				this.$refs.refPopupCalibration.close()
 				this.teachingStatus = ""
 			},
-			showError(ex) {
-				let exStr = JSON.stringify(ex)
-				if (exStr == "{}")
-					exStr = ex
-				let tip = typeof ex.msg == "string" ? ex.msg : exStr
-				showModal(tip, "閿欒", false)
-			},
-
 
 		}
 	}

--
Gitblit v1.9.1