From 68ce9382090846dc3a03a057a18a7d09f30e45e5 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期五, 17 十月 2025 17:39:03 +0800
Subject: [PATCH] test

---
 pages/map/index.vue |  256 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 205 insertions(+), 51 deletions(-)

diff --git a/pages/map/index.vue b/pages/map/index.vue
index 9240203..7c03354 100644
--- a/pages/map/index.vue
+++ b/pages/map/index.vue
@@ -211,17 +211,21 @@
 				<view class="bottom-content" v-if="mapOperationStatus =='teaching'">
 					<view class="tip">璺緞璁板綍涓�..</view>
 					<view v-if="mapOperationType =='public_teaching'">
+						<!-- 涓昏矾/鏀矾 -->
 						<view>姝e湪璁板綍鎼繍杞﹁杩涜矾寰勶紝瀹屾垚鍚庣偣鎸夐挳浠ョ粨鏉熺ず鏁欍�鍦ㄧず鏁欒繃绋嬩腑鍙互娣诲姞绔欑偣銆�/view>
-						<!-- 		<view class="switch-type">鍙殢鏃跺垏鎹富璺�鏀矾绀烘暀锛�+						<view class="switch-type">鍙殢鏃跺垏鎹㈢ず鏁欐ā寮� 							<view class="switch-button-group">
 								<view class="switch-button"
-									:class="teachingModeCur.main_road ==1?'switch-button-checked':''"
-									@click="onTeachingModeMainRoad(1)">涓昏矾绀烘暀</view>
+									:class="teachingModeCur.mode_type ==0?'switch-button-checked':''"
+									@click="onTeachingModeType(0)">榛樿</view>
 								<view class="switch-button "
-									:class="teachingModeCur.main_road ==0?'switch-button-checked':''"
-									@click="onTeachingModeMainRoad(0)">鏀矾绀烘暀</view>
+									:class="teachingModeCur.mode_type ==1?'switch-button-checked':''"
+									@click="onTeachingModeType(1)">鍙屽悜</view>
+								<view class="switch-button "
+									:class="teachingModeCur.mode_type ==2?'switch-button-checked':''"
+									@click="onTeachingModeType(2)">鏅鸿兘</view>
 							</view>
-						</view> -->
+						</view>
 					</view>
 
 					<view v-else>
@@ -258,17 +262,20 @@
 				<view class="bottom-content" v-else>
 					<view class="tip">鍗冲皢寮�鍏叡绀烘暀</view>
 					<view>
-						璇烽�鎷╄杩涜涓昏矾杩樻槸鏀矾绀烘暀锛岀偣銆愬紑濮嬭褰曘�鍚庡皢璁板綍鎼繍杞︾殑琛岃繘璺嚎浣滀负鍏叡绀烘暀璺嚎銆傚紑濮嬭褰曞悗鍙殢鏃跺垏鎹富璺�鏀矾绀烘暀銆�+						璇烽�鎷╄杩涜涓昏矾杩樻槸鏀矾绀烘暀锛岀偣銆愬紑濮嬭褰曘�鍚庡皢璁板綍鎼繍杞︾殑琛岃繘璺嚎浣滀负鍏叡绀烘暀璺嚎銆傚紑濮嬭褰曞悗鍙殢鏃跺垏鎹㈢ず鏁欐ā寮忋�
 					</view>
 					<view class="text-button-group">
 						<view class="switch-type">
 							<view class="switch-button-group">
 								<view class="switch-button"
-									:class="teachingModeCur.main_road ==1?'switch-button-checked':''"
-									@click="onTeachingModeMainRoad(1)">涓昏矾绀烘暀</view>
+									:class="teachingModeCur.mode_type ==0?'switch-button-checked':''"
+									@click="onTeachingModeType(0)">榛樿</view>
 								<view class="switch-button "
-									:class="teachingModeCur.main_road ==0?'switch-button-checked':''"
-									@click="onTeachingModeMainRoad(0)">鏀矾绀烘暀</view>
+									:class="teachingModeCur.mode_type ==1?'switch-button-checked':''"
+									@click="onTeachingModeType(1)">鍙屽悜</view>
+								<view class="switch-button "
+									:class="teachingModeCur.mode_type ==2?'switch-button-checked':''"
+									@click="onTeachingModeType(2)">鏅鸿兘</view>
 							</view>
 						</view>
 						<a-button type="primary" class="button" :disabled="loading"
@@ -383,6 +390,39 @@
 
 				</view>
 			</uni-popup>
+			<uni-popup ref="refPopupTeachingUpdate" type="dialog">
+				<uni-popup-dialog type="info" cancelText="鍙栨秷" confirmText="纭畾" title="绀烘暀鏇存柊"
+					@confirm="dialogTeachingUpdateConfirm" @close="dialogTeachingUpdateClose">
+
+					<view class="popup-dialog-content">
+						<view class="popup-content-item">
+							<radio-group @change="radioTeachinMainRoadChange">
+								<label class="radio">
+									<radio :value="1" :checked="selectTeachingMode.main_road == 1" />涓昏矾
+								</label>
+								<label class="radio">
+									<radio :value="0" :checked="selectTeachingMode.main_road != 1" />鏀矾
+								</label>
+							</radio-group>
+
+
+						</view>
+						<view class="popup-content-item">
+							<radio-group @change="radioTeachinBidirectionChange">
+								<label class="radio">
+									<radio :value="1" :checked="selectTeachingMode.bidirection == 1" />鍙屽悜
+								</label>
+								<label class="radio">
+									<radio :value="0" :checked="selectTeachingMode.bidirection != 1" />鍗曞悜
+								</label>
+							</radio-group>
+
+						</view>
+					</view>
+				</uni-popup-dialog>
+			</uni-popup>
+
+
 
 		</view>
 	</view>
@@ -423,6 +463,9 @@
 		delTeachingMode,
 		delTeachingModeData,
 		checkAgvLocationDistanceError,
+		splitTeachingMode,
+		updateSplitTeachingData,
+		deleteSplitTeachingData
 	} from "@/api/vehicle.js"
 	export default {
 		name: "PagesMap",
@@ -477,6 +520,7 @@
 				unlinked: false,
 				showTeachingPathFlag: true,
 				curTeachingPathFlag: false,
+				curTeachingPathTime: 0,
 				curMapInfo: {
 					proportion: 1,
 					img_proportion: 1,
@@ -761,6 +805,7 @@
 									'save') {
 									try {
 										await delTeachingMode(this.vehicleIp, [this.teachingModeCur])
+
 										listDataStr.push({
 											method: "remove_teaching_path",
 											param: {
@@ -788,7 +833,7 @@
 					}
 
 				} else {
-				
+
 					const eventChannel = this.getOpenerEventChannel();
 					eventChannel.emit('check_connect', !this.unlinked);
 					uni.navigateBack({
@@ -1029,7 +1074,7 @@
 						height: param.view?.height || 0,
 					}
 					const angle = this.getStantardAngle(this.stationEdit.angle * 180 / Math.PI)
-					
+
 					this.angleSvg = `/static/images/angle${angle}.svg`
 					this.mapOperationType = ""
 
@@ -1143,14 +1188,18 @@
 					} else if (param.type == "public") {
 						this.selectTeachingMode = {
 							mode: "Public",
+							edge_name: param.data?.edge_name || "",
 							name: param.data?.name || "",
-							point: param.point
+							point: param.point,
+							main_road: param.data?.main_road || 0,
+							bidirection: param.data?.bidirection || 0,
 						}
+						console.log(this.selectTeachingMode.main_road, this.selectTeachingMode)
 					}
 					this.$refs.refPopupOperateTeaching.open("bottom")
 				} else if (param.method == "cancel_positioning_agv") {
-					if (this.mapOperationType == "public_teaching" 
-					&& this.mapOperationStatus == "teaching") {
+					if (this.mapOperationType == "public_teaching" &&
+						this.mapOperationStatus == "teaching") {
 						this.positioningAgv = true
 					} else
 						this.positioningAgv = false
@@ -1208,7 +1257,7 @@
 				this.mapOperationStatus = ""
 				this.teachingModeCur = {
 					mode: "Public",
-					main_road: 1,
+					mode_type: 0,
 				}
 				this.positioningAgv = true
 				this.mapOperationType = "public_teaching"
@@ -1230,7 +1279,7 @@
 			async loadSceneList() {
 				try {
 
-					
+
 					const _this = this
 					const res = await getAllScene(this.vehicleIp) || []
 					const list = res?.sceneList || []
@@ -1263,7 +1312,7 @@
 
 				} catch (ex) {
 					showError(ex)
-				} 
+				}
 			},
 			clickDelete() {
 				const _this = this
@@ -1928,7 +1977,7 @@
 				try {
 					const {
 						data
-					} = await getTeachingMode(this.vehicleIp)
+					} = await splitTeachingMode(this.vehicleIp)
 					return data || {
 						Public: [],
 						Stations: []
@@ -2038,10 +2087,19 @@
 							}
 						})
 						if (list.length > 0) {
+							this.curTeachingPathTime += 1
 							this.curTeachingPathFlag = true
+							if (this.curTeachingPathTime % 5 == 0) {
+								const listStationCtxData = await this.getRefreshStationCtxData() || []
+								if (listStationCtxData.length > 0) {
+									listCtrData.push(...listStationCtxData)
+								}
+							}
 						} else {
 							if (this.curTeachingPathFlag) {
 								this.curTeachingPathFlag = false
+								this.curTeachingPathTime = 0
+
 								const teaching = await this.loadTeachingMode()
 
 								const publicOld = this.teachingMode.Public || []
@@ -2052,8 +2110,8 @@
 								const stationAdd = []
 								for (let i in publicNew) {
 									const item = publicNew[i]
-									const curIndex = publicOld.findIndex((a) => a.name == item.name)
-									console.log(curIndex, item)
+									const curIndex = publicOld.findIndex((a) => a.name == item.name && a.edge_name == item.edge_name )
+									
 									if (curIndex < 0) {
 										publicAdd.push(item)
 										publicOld.push(item)
@@ -2089,6 +2147,10 @@
 											show: this.showTeachingPathFlag
 										}
 									})
+								}
+								const listStationCtxData = await this.getRefreshStationCtxData() || []
+								if (listStationCtxData.length > 0) {
+									listCtrData.push(...listStationCtxData)
 								}
 							}
 						}
@@ -2133,7 +2195,45 @@
 				}
 
 			},
+			async getRefreshStationCtxData() {
+				try {
+					const listCtrData = []
+					const listOld = this.stationList
+					const listId = listOld.map((a) => a.stationID)
+					const stationLst = await this.loadStations()
+					const listNew = stationLst.filter((a) => {
+						return !listId.includes(a.stationID)
+					})
+					// console.log(listId.length,listNew.length,stationLst.length)
+					// console.log(listId)
+					if (listId.length + listNew.length > stationLst.length) {
+						const listId2 = stationLst.map((a) => a.stationID)
 
+						const listRemove = listOld.filter((a) => {
+							return !listId2.includes(a.stationID)
+						})
+						if (listRemove.length > 0) {
+							listCtrData.push({
+								method: "remove_station",
+								param: listRemove
+							})
+							this.stationList = stationLst
+						}
+					}
+					if (listNew.length > 0) {
+						listCtrData.push({
+							method: "add_station",
+							param: listNew
+						})
+						this.stationList = stationLst
+					}
+					return listCtrData
+				} catch (ex) {
+
+					showToast(ex)
+					return []
+				}
+			},
 			askTeachingBiDirection(teachingMode) {
 				showModal("閫夋嫨褰撳墠绀烘暀璺嚎绫诲瀷?", "绀烘暀缁撴潫", true, "鍙屽悜璺嚎",
 					"鍗曞悜璺嚎").then((res) => {
@@ -2263,15 +2363,15 @@
 						}
 					} else {*/
 
-					const main_road = this
+					const mode_type = this
 						.teachingModeCur
-						.main_road
+						.mode_type
 					this.teachingModeCur = {
 						mode: "Public",
 						src_dst: ``,
 						name: "",
 						teaching_flag: 1,
-						main_road
+						mode_type
 					}
 					const res2 =
 						await teachingModeFlag(
@@ -2300,10 +2400,12 @@
 					// } else {
 					// 	this.askTeachingBiDirection(this.teachingModeCur)
 					// }
-					this.askTeachingBiDirection(
-						this
-						.teachingModeCur
-					)
+					// this.askTeachingBiDirection(
+					// 	this
+					// 	.teachingModeCur
+					// )
+					this.teachingModeCur.teaching_flag = 0
+					await this.finishTeaching(this.teachingModeCur)
 				} catch (ex) {
 					showError(ex)
 				} finally {
@@ -2311,22 +2413,29 @@
 				}
 
 			},
-			async onTeachingModeMainRoad(val) {
+			async onTeachingModeType(val) {
 				try {
 					if (this.mapOperationStatus) {
 
-						if (this.teachingModeCur.main_road == val) {
+						if (this.teachingModeCur.mode_type == val) {
 							return
 						}
 						this.teachingModeCur.teaching_flag = 0
 						const oldName = this.teachingModeCur.name
 						await teachingModeFlag(this.vehicleIp, this.teachingModeCur)
-						this.teachingModeCur.main_road = val
+						this.teachingModeCur.mode_type = val
 						this.teachingModeCur.teaching_flag = 1
 						this.teachingModeCur.mode = "Public"
 						this.teachingModeCur.name = ""
-						const res = await teachingModeFlag(this.vehicleIp, this.teachingModeCur)
-						if (val == 0)
+						const res = await teachingModeFlag(this.vehicleIp, this
+							.teachingModeCur)
+						if (val == 1)
+							showToast("宸插皢绀烘暀鍒囨崲鎴愬弻鍚戞ā寮�)
+						else if (val == 2)
+							showToast("宸插皢绀烘暀鍒囨崲鎴愭櫤鑳芥ā寮�)
+						else
+							showToast("宸插皢绀烘暀鍒囨崲鎴愰粯璁ゆā寮�)
+						/*if (val == 0)
 							showToast(
 								"宸插皢璇ヨ矾娈佃矾寰勪繚瀛樹负涓昏矾绀烘暀璺嚎"
 							)
@@ -2339,7 +2448,7 @@
 
 						const {
 							data
-						} = await getTeachingMode(this.vehicleIp)
+						} = await splitTeachingMode(this.vehicleIp)
 
 						const publicList = data.Public || []
 						const curIndex = publicList.findIndex((a) => a.name == oldName)
@@ -2354,12 +2463,10 @@
 							}])
 
 						}
-
+*/
 
 					} else {
-						this.teachingModeCur
-							.main_road =
-							val
+						this.teachingModeCur.mode_type = val
 					}
 
 				} catch (ex) {
@@ -2377,16 +2484,48 @@
 			},
 
 			clickTeachingEdit() {
-				this.$refs
-					.refPopupOperateTeaching
-					.close()
-				this.mapOperationType =
-					"edit_teaching"
-				this.ctxDataStr = JSON
-					.stringify([{
-						method: "edit_teaching",
-						param: this.selectTeachingMode,
-					}])
+				this.$refs.refPopupOperateTeaching.close()
+				this.$refs.refPopupTeachingUpdate.open("")
+
+				// this.mapOperationType =
+				// 	"edit_teaching"
+				// this.ctxDataStr = JSON
+				// 	.stringify([{
+				// 		method: "edit_teaching",
+				// 		param: this.selectTeachingMode,
+				// 	}])
+			},
+			radioTeachinMainRoadChange(evt) {
+				this.selectTeachingMode.main_road = evt.detail.value
+			},
+			radioTeachinBidirectionChange(evt) {
+				this.selectTeachingMode.bidirection = evt.detail.value
+			},
+			async dialogTeachingUpdateConfirm() {
+				try {
+					uni.showLoading({
+						title: "鏇存柊绀烘暀涓�
+					})
+					const item = this.selectTeachingMode
+					await updateSplitTeachingData(this.vehicleIp, item)
+					this.ctxDataStr =
+						JSON.stringify(
+							[{
+								method: "update_teaching",
+								param: item,
+							}])
+					this.selectTeachingMode = {}
+					showToast("鏇存柊绀烘暀鎴愬姛")
+				} catch (ex) {
+					showError(
+						ex)
+				} finally {
+					uni.hideLoading()
+				}
+			},
+			dialogTeachingUpdateClose() {
+				this.$refs.refPopupTeachingUpdate.close()
+
 			},
 
 			async removeTeachingMode(item) {
@@ -2394,13 +2533,16 @@
 					uni.showLoading({
 						title: "鍒犻櫎绀烘暀涓�
 					})
-					await delTeachingMode(this.vehicleIp, [item])
+					await deleteSplitTeachingData(this.vehicleIp, item
+						.edge_name, item.name)
+					//await delTeachingMode(this.vehicleIp, [item])
 					this.ctxDataStr =
 						JSON.stringify(
 							[{
 								method: "remove_teaching_path",
 								param: item,
 							}])
+					showToast("鍒犻櫎绀烘暀鎴愬姛")
 				} catch (ex) {
 					showError(
 						ex)
@@ -2414,6 +2556,7 @@
 						title: "鍒犻櫎绀烘暀鏁版嵁涓�
 					})
 					await delTeachingModeData(this.vehicleIp, data)
+					showToast("鍒犻櫎绀烘暀鎴愬姛")
 					this.reloadTeachingMode()
 				} catch (ex) {
 					showError(ex)
@@ -2857,12 +3000,14 @@
 						height: 32px;
 						line-height: 32px;
 						text-align: center;
+						box-shadow: 0px 2px 8px 0px #0000000C;
 					}
 
 					.switch-button-checked {
 						box-shadow: 0px 2px 8px 0px #0000000C;
 						background-color: #fff;
-						color: #262626;
+						color: #1890FF;
+
 					}
 
 				}
@@ -2884,6 +3029,15 @@
 			background-color: transparent;
 		}
 
+		.popup-dialog-content {
+			display: flex;
+			flex-direction: column;
+
+			.popup-content-item {
+				padding: 10rpx;
+			}
+		}
+
 		.popup-content-menu {
 			margin-top: 140rpx;
 			margin-left: 225rpx;

--
Gitblit v1.9.1