From bcfb05f5e7782ef23e4deb1b38a1ca4b4085181a Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期六, 11 十月 2025 17:09:47 +0800
Subject: [PATCH] test

---
 pages/map/js/ctx.js |   65 +++++++--
 api/vehicle.js      |   21 +++
 pages/map/scene.vue |  127 ++++++++---------
 pages/map/index.vue |  196 ++++++++++++++++++++-------
 4 files changed, 275 insertions(+), 134 deletions(-)

diff --git a/api/vehicle.js b/api/vehicle.js
index 250dbe8..47f4d43 100644
--- a/api/vehicle.js
+++ b/api/vehicle.js
@@ -871,6 +871,27 @@
 }
 
 /**
+ * GET 6000/api/get_map_server_phase
+ * 鑾峰彇鏋勫浘绋嬪簭闃舵
+ * @param 
+ * @returns 
+ * "data": 1,  # 1锛氭湭鍚姩2锛氬惎鍔ㄤ腑3锛氬惎鍔ㄥ畬鎴�锛氭瀯鍥句繚瀛樹腑5锛氭瀯鍥句繚瀛樺畬鎴�锛氭瀯鍥句繚瀛樺け璐�+ */
+
+export const getMapServerPhase = (ip) => {
+	var header = {
+		"Content-Type": "application/json;charset=UTF-8"
+	};
+	var url = `http://${ip}:5000/api/get_map_server_phase/`;
+	return http.request({
+		method: "GET",
+		url,
+		header,
+	})
+}
+
+
+/**
  * POST 5000/api/update_scene_id
  * 淇敼鍦烘櫙鍚嶇О
  * @param 
diff --git a/pages/map/index.vue b/pages/map/index.vue
index 9240203..1c35489 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>
+
+						<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>
+						<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>
+
+				</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",
@@ -760,7 +803,10 @@
 								if (this.mapOperationStatus == 'end' || this.mapOperationStatus ==
 									'save') {
 									try {
-										await delTeachingMode(this.vehicleIp, [this.teachingModeCur])
+										//	await delTeachingMode(this.vehicleIp, [this.teachingModeCur])
+										await deleteSplitTeachingData(this.vehicleIp, this.teachingModeCur
+											.edge_name, this.teachingModeCur.name)
+
 										listDataStr.push({
 											method: "remove_teaching_path",
 											param: {
@@ -788,7 +834,7 @@
 					}
 
 				} else {
-				
+
 					const eventChannel = this.getOpenerEventChannel();
 					eventChannel.emit('check_connect', !this.unlinked);
 					uni.navigateBack({
@@ -1029,7 +1075,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 +1189,17 @@
 					} 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?.name || 0,
 						}
 					}
 					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: []
@@ -2196,7 +2245,9 @@
 						if (res) {
 							try {
 								this.loading = true
-								await delTeachingMode(_this.vehicleIp, [_this.teachingModeCur])
+								//await delTeachingMode(_this.vehicleIp, [_this.teachingModeCur])
+								await deleteSplitTeachingData(_this.vehicleIp, _this.teachingModeCur.edge_name,
+									_this.teachingModeCur.name)
 								_this.mapOperationStatus = ""
 								const listDataStr = []
 								listDataStr.push({
@@ -2263,15 +2314,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 +2351,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 +2364,28 @@
 				}
 
 			},
-			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)
+						if (val == 1)
+							showToast("宸插皢绀烘暀鍒囨崲鎴愬弻鍚戞ā寮�)
+						else if (val == 2)
+							showToast("宸插皢绀烘暀鍒囨崲鎴愭櫤鑳芥ā寮�)
+						else
+							showToast("宸插皢绀烘暀鍒囨崲鎴愰粯璁ゆā寮�)
+						/*if (val == 0)
 							showToast(
 								"宸插皢璇ヨ矾娈佃矾寰勪繚瀛樹负涓昏矾绀烘暀璺嚎"
 							)
@@ -2339,7 +2398,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 +2413,10 @@
 							}])
 
 						}
-
+*/
 
 					} else {
-						this.teachingModeCur
-							.main_road =
-							val
+						this.teachingModeCur.mode_type = val
 					}
 
 				} catch (ex) {
@@ -2377,16 +2434,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(e) {
+				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 +2483,15 @@
 					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)
@@ -2413,7 +2504,9 @@
 					uni.showLoading({
 						title: "鍒犻櫎绀烘暀鏁版嵁涓�
 					})
-					await delTeachingModeData(this.vehicleIp, data)
+					await deleteSplitTeachingData(this.vehicleIp, data.edge_name, data.name)
+					//await delTeachingModeData(this.vehicleIp, data)
+					showToast("鍒犻櫎绀烘暀鎴愬姛")
 					this.reloadTeachingMode()
 				} catch (ex) {
 					showError(ex)
@@ -2862,7 +2955,8 @@
 					.switch-button-checked {
 						box-shadow: 0px 2px 8px 0px #0000000C;
 						background-color: #fff;
-						color: #262626;
+						color: #1890FF;
+
 					}
 
 				}
diff --git a/pages/map/js/ctx.js b/pages/map/js/ctx.js
index 9af2077..7479ccf 100644
--- a/pages/map/js/ctx.js
+++ b/pages/map/js/ctx.js
@@ -2114,11 +2114,11 @@
 				fromY = pt2.y
 			}
 			let strokeWidth = 5
-			let stroke = "#95DE64"
+			let stroke = "#69C0FF"
 
-			if (main_road == 1) {
-				stroke = "#69C0FF"
-			}
+			// if (main_road == 1) {
+			// 	stroke = "#69C0FF"
+			// }
 			const objPath = new fabric.Path(
 				path2, {
 					id: "current_teaching",
@@ -2154,7 +2154,7 @@
 
 			const theta = 20;
 			let headlen = 10;
-			var main_road = 1
+			var main_road = teachingData.main_road || 0
 
 			const len = pos_list.length
 			let fromX = 0,
@@ -2238,10 +2238,11 @@
 					// }
 					path2 += ` L${pt2.x} ${pt2.y}`
 				} else {
-					main_road = pt.main_road
-					if (main_road == 1) {
-						headlen = 15
-					}
+					if (pt.main_road)
+						main_road = pt.main_road
+					// if (main_road == 1) {
+					// 	headlen = 15
+					// }
 					path2 = `M${pt2.x} ${pt2.y}`
 				}
 				fromX = pt2.x
@@ -2252,19 +2253,21 @@
 
 			// console.log("addTeachingPath",path2)
 			// path2 += " Z"
-			let strokeWidth = 2
-			let stroke = "#95DE64"
+			let strokeWidth = 1.5
+			let stroke = "#69C0FF"
 			if (type == "station_teaching") {
 				stroke = "#69C0FF"
 			} else {
 				if (main_road == 1) {
-					stroke = "#69C0FF"
-					if (teachingData.bidirection == 1) {
-						stroke = "#FF00FF"
-					}
-				} else {
+					//stroke = "#69C0FF"
 					if (teachingData.bidirection == 1) {
 						stroke = "#ffaa00"
+					}
+					strokeWidth = 3
+
+				} else {
+					if (teachingData.bidirection == 1) {
+						stroke = "#FF00FF"
 					}
 				}
 			}
@@ -2302,6 +2305,7 @@
 
 			return objPath
 		},
+
 		isObjectFullyContained(outerObj, innerObj) {
 			const outer = outerObj.getBoundingRect(true, true);
 			const inner = innerObj.getBoundingRect(true, true);
@@ -3649,6 +3653,35 @@
 						const teachingMode = item.param
 						_this.showEditTeachingPath(teachingMode)
 
+					} else if (item.method == "update_teaching") {
+						let list = _this.canvas.getObjects() || []
+						list = list.filter((a) => a.eleType == "public_teaching")
+						const id = `public_teaching_${item.param.name}`
+						const curIndex = list.findIndex((a) => a.id == id)
+						if (curIndex > -1) {
+							const obj = list[curIndex]
+
+
+
+							let strokeWidth = 1.5
+							let stroke = "#69C0FF"
+
+							if (item.param.main_road == 1) {
+								//stroke = "#69C0FF"
+								if (item.param.bidirection == 1) {
+									stroke = "#ffaa00"
+								}
+								strokeWidth = 3
+
+							} else {
+								if (item.param.bidirection == 1) {
+									stroke = "#FF00FF"
+								}
+							}
+
+							obj.set({strokeWidth,stroke})
+
+						}
 					} else if (item.method == "set_selectable") {
 						if (item.param)
 							_this.setAllObjectSelectable(true)
diff --git a/pages/map/scene.vue b/pages/map/scene.vue
index 5e73943..aa7af12 100644
--- a/pages/map/scene.vue
+++ b/pages/map/scene.vue
@@ -43,7 +43,8 @@
 			<view class="bottom-content" v-else-if="opSceneType =='scan'">
 				<view class="tip">鍦烘櫙鏋勫缓涓�/view>
 				<view>
-					璇锋搷浣滄惉杩愯溅鎵弿鍦板浘瑕嗙洊鐨勫尯鍩�+					<!-- 璇锋搷浣滄惉杩愯溅鎵弿鍦板浘瑕嗙洊鐨勫尯鍩�-->
+					{{mapServerPhase=== 1  ?"鍦烘櫙鏋勫缓鏈嶅姟锛氭湭鍚姩":mapServerPhase===2 ?"鍦烘櫙鏋勫缓鏈嶅姟锛氬惎鍔ㄤ腑":mapServerPhase===3  ?"鍦烘櫙鏋勫缓涓�:mapServerPhase}}
 				</view>
 
 				<view class="text-button-group">
@@ -51,13 +52,17 @@
 				</view>
 			</view>
 			<view class="bottom-content" v-else-if="opSceneType =='finish'">
-				<view class="tip"> 鈥渰{sceneName}}鈥漿{opType == "extend"?"鍦烘櫙鎵╁睍瀹屾垚"+"":"鍦烘櫙鏋勫缓瀹屾垚"}}</view>
-			<!-- 	<view> 宸叉垚鍔熸瀯寤衡�{{sceneName}}鈥�/view> -->
-				<view class="loading-view">{{saveMapIsOk?"鏋勫浘淇濆瓨瀹屾垚":"绛夊緟鏋勫浘淇濆瓨瀹屾垚..."}}
-					<view v-if="!saveMapIsOk" class="auto-circle"></view>
+				<view class="tip"> 鈥渰{sceneName}}鈥漿{opType == "extend"?"鍦烘櫙鎵╁睍缁撴潫"+"":"鍦烘櫙鏋勫缓缁撴潫"}}</view>
+				<!-- 	<view> 宸叉垚鍔熸瀯寤衡�{{sceneName}}鈥�/view> -->
+				<view class="loading-view">
+					鏋勫浘鐘舵�锛歿{mapServerPhase===5?"淇濆瓨鎴愬姛":mapServerPhase===4?"淇濆瓨涓�:mapServerPhase===6?"淇濆瓨澶辫触":mapServerPhase}}
+					<view v-if="mapServerPhase === 4" class="auto-circle"></view>
 				</view>
 				<view class="text-button-group">
-					<a-button type="primary" class="button" :disabled=" !saveMapIsOk || loading" @click="clickFinish">{{opType == "extend"?"鎵╁睍瀹屾垚":"鏋勫缓瀹屾垚"}}</a-button>
+					<a-button type="primary" class="button" v-if="mapServerPhase === 6"
+						@click="clickRecreate">{{opType == "extend"?"閲嶇幇鎵╁睍":"閲嶇幇鏋勫缓"}}</a-button>
+					<a-button type="primary" class="button" v-else :disabled=" mapServerPhase !==5 || loading"
+						@click="clickFinish">{{opType == "extend"?"鎵╁睍瀹屾垚":"鏋勫缓瀹屾垚"}}</a-button>
 				</view>
 			</view>
 		</view>
@@ -81,13 +86,15 @@
 		createScene,
 		addMap,
 		stopMap,
+		delScene,
 		//getAgvState,
 		getMapLaserData,
 		saveDBData,
-		checkMapServerIsStart,
-		startOrStopMapServer,
-		checkMapServerIsOk,
-		checkSaveMapIsOk,
+		// checkMapServerIsStart,
+		// startOrStopMapServer,
+		// checkMapServerIsOk,
+		// checkSaveMapIsOk,
+		getMapServerPhase,
 		getMapUrl
 
 	} from "@/api/vehicle.js"
@@ -110,7 +117,7 @@
 				localSceneList: [],
 				positioningAgv: true,
 				robotPos: {},
-				mapserverIsOk: false,
+				mapServerPhase: 1,
 				extendBase64Img: "",
 				saveMapIsOk: false,
 				destroyFlag: false,
@@ -210,7 +217,6 @@
 			async loadData() {
 				try {
 
-					// this.loadMapServerState()
 					if (this.opType == "") {
 						this.localSceneList = await this.loadLocalScene()
 					} else {
@@ -218,7 +224,9 @@
 							this.opSceneType = "add_name"
 						}
 						if (this.opType == "extend") {
+							this.mapServerPhase = 1
 							await addMap(this.ip, this.sceneName, "extend")
+							this.checkMapServerPhase()
 							this.opSceneType = 'scan'
 						}
 						// if (this.opType == "extend") {
@@ -234,7 +242,7 @@
 						// }
 
 					}
-					
+
 					this.refreshMapLaserData()
 
 
@@ -252,58 +260,22 @@
 					return {}
 				}
 			},
-			async loadMapServerState() {
+			async checkMapServerPhase() {
 				try {
 
-					this.mapserverIsOk = false
-					const res = await checkMapServerIsStart(this.ip)
-					if (res) {
-						this.mapserverIsOk = true
-					} else {
-						this.mapserverIsOk = false
-						const res = await startOrStopMapServer(this.ip, 1)
-						if (res) {
-							this.checkMapServerState()
-						}
+					const res = await getMapServerPhase(this.ip)
+					this.mapServerPhase = res || 1
+					if (this.mapServerPhase === 3) {
+						return
 					}
-				} catch (ex) {
-
-					showError(ex)
-				}
-			},
-
-			async checkMapServerState() {
-				try {
-
-					const res = await checkMapServerIsOk(this.ip)
-					if (res) {
-						this.mapserverIsOk = true
-					} else {
-						this.mapserverIsOk = false
-						setTimeout(this.checkMapServerState, 1000);
-					}
-
-				} catch (ex) {
-					showError(ex).then((res) => {
-						setTimeout(this.checkMapServerState, 1000);
-					})
-				}
-			},
-			async checkSaveMapState() {
-				try {
-
-					const res = await checkSaveMapIsOk(this.ip)
-					if (res) {
+					if (this.mapServerPhase === 5 || this.mapServerPhase === 6) {
 						this.saveMapIsOk = true
-					} else {
-						this.saveMapIsOk = false
-						setTimeout(this.checkSaveMapState, 1000);
+						return
 					}
-
+					setTimeout(this.checkMapServerPhase, 1000);
 				} catch (ex) {
-					showError(ex).then((res) => {
-						setTimeout(this.checkSaveMapState, 1000);
-					})
+					showToast(ex)
+					setTimeout(this.checkMapServerPhase, 1000);
 				}
 			},
 
@@ -383,7 +355,9 @@
 				try {
 					this.mapId = ""
 					if (this.opType == "extend") {
+						this.mapServerPhase = 1
 						await addMap(this.ip, this.sceneName, "extend")
+						this.checkMapServerPhase()
 						this.opSceneType = 'scan'
 					} else {
 						this.opSceneType = "add_name"
@@ -437,6 +411,7 @@
 					this.sceneName = name
 					await createScene(this.ip, name, 1)
 					await addMap(this.ip, name)
+					this.checkMapServerPhase()
 					uni.showLoading({
 						title: "寮�鎵弿鍦板浘"
 					})
@@ -476,8 +451,8 @@
 					})
 					this.saveMapIsOk = false
 					await stopMap(this.ip, this.sceneName)
-					// await startOrStopMapServer(this.ip, 2)
-					// this.checkSaveMapState();
+					this.mapServerPhase = 4
+					this.checkMapServerPhase();
 					// if (this.opType == "extend") {
 					// 	this.opSceneType = ""
 					// 	const eventChannel = this.getOpenerEventChannel();
@@ -486,13 +461,12 @@
 					// 		delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
 					// 	})
 					// }
-					setTimeout(() => {this.saveMapIsOk = true}, 5000);
-					
+
 				} catch (ex) {
 					console.log(ex)
 					showModal("璇锋鏌ヨ溅杈嗚繛鎺ワ紝骞堕噸鏂板紑濮嬫瀯寤哄満鏅�, "鍦烘櫙鏋勫缓澶辫触", false, "纭畾").then((res) => {
 						this.opSceneType = ''
-						// this.loadMapServerState()
+
 					})
 				} finally {
 					this.loading = false
@@ -519,9 +493,28 @@
 					this.loading = false
 					uni.hideLoading()
 				}
-
-
 			},
+			async clickRecreate() {
+				try {
+					if (this.opType == "extend") {
+						this.mapServerPhase = 1
+						await addMap(this.ip, this.sceneName, "extend")
+						this.checkMapServerPhase()
+						this.opSceneType = 'scan'
+					} else {
+						this.mapServerPhase = 1
+						await delScene(this.ip, this.sceneName)
+						await createScene(this.ip, this.sceneName, 1)
+						await addMap(this.ip, this.sceneName)
+						this.checkMapServerPhase()
+						this.opSceneType = 'scan'
+					}
+				} catch (ex) {
+					console.log(ex)
+				}
+			},
+
+
 			async loadMapLaserData() {
 				try {
 					const info = await getMapLaserData(this.ip, this.mapId)
@@ -603,7 +596,7 @@
 							}
 						}
 					}
-					
+
 					setTimeout(this.refreshMapLaserData, 1000);
 				} catch (ex) {
 					showToast(ex)

--
Gitblit v1.9.1