cuiqian2004
2025-10-17 68ce9382090846dc3a03a057a18a7d09f30e45e5
pages/map/index.vue
@@ -10,22 +10,22 @@
                  alt="SVG 图片" @click="clickShowMenu" />
            </view>
            <template v-slot:left>
               <view>
                  <uni-icons type="left" size="24" @click="clickBack"></uni-icons>
               <view @click="clickBack">
                  <uni-icons type="left" size="24"></uni-icons>
               </view>
            </template>
            <template v-slot:right>
            <!-- <template v-slot:right>
               <view v-if="sceneList.length > 0 && !mapOperationType">
                  <a @click="clickMore">
                     <uni-icons class="uni-panel-bar-icon" type="more-filled" size="24"></uni-icons>
                  </a>
               </view>
            </template>
            </template> -->
         </uni-nav-bar>
         <view class="no-content" v-if="unlinked">
            <image class="img" src="/images/image 25.png" alt=" 图片" mode="aspectFit" />
            <image class="img" src="/images/image_25.png" alt=" 图片" mode="aspectFit" />
            <view class="title">车辆连接失败</view>
            <view class="space">请检查你的网络设置或重新加载</view>
         </view>
@@ -33,7 +33,9 @@
            v-model:opSceneType="opSceneType" @create-ok="onCreateSceneOk"></SceneCreateInfo> -->
         <view class="map-content" v-show="mapOperationType !='scene_create'">
            <view class="content">
               <view class="fabric" :message="ctxDataStr" :change:message="ctx.receiveMsg" id="canvasMap"></view>
               <view ref="canvasCtx" class="fabric" id="canvasMap" :message="ctxDataStr"
                  :change:message="ctx.receiveMsg">
               </view>
               <view class="loading-overlay" v-if="bgLoading">
                  <view class="loading-content">
                     <view class="loading-spinner"></view>
@@ -87,7 +89,7 @@
            <view class="tip">请输入场景名称</view>
            <view class="name-input">
               <input ref="refInputName" :focus="true" placeholder="请输入场景名称" :value="sceneInputName"
                  @input="onInputName"></input>
                  @input="onInputName" />
               <uni-icons class="clear" color="#ccc" type="clear" size="20" v-if="sceneInputName"
                  @click="clickClearName"></uni-icons>
            </view>
@@ -106,14 +108,14 @@
                  <view class="coordinate">
                     <text class="name">横坐标:</text>
                     <input ref="refInputX" class="number-input" type="number" :value="stationEdit.x"
                        @input="onInputStationX" :maxlength="4"></input>
                        @input="onInputStationX" :maxlength="4" />
                     <uni-icons class="clear" color="#ccc" type="clear" size="20"
                        v-if="stationEdit.x && stationEdit.x!='0'" @click="clickClearStationX"></uni-icons>
                  </view>
                  <view class="coordinate">
                     <text class="name">竖坐标:</text>
                     <input ref="refInputX" class="number-input" type="number" :value="stationEdit.y"
                        @input="onInputStationY" :maxlength="4"></input>
                        @input="onInputStationY" :maxlength="4" />
                     <uni-icons class="clear" color="#ccc" type="clear" size="20"
                        v-if="stationEdit.y&& stationEdit.y!='0'" @click="clickClearStationY"></uni-icons>
                  </view>
@@ -122,7 +124,7 @@
               <view class="tip">调节朝向</view>
               <view class="angle-group">
                  <image class="img-angle" :src="angleSvg" alt="SVG 图片" />
                  <image class="img-angle-pos" src="/images/Frame 153.svg" alt="SVG 图片"
                  <image class="img-angle-pos" src="/images/Frame_153.svg" alt="SVG 图片"
                     @touchstart="handleAngleTouchStart" @touchmove="handleAngleTouchMove" />
               </view>
            </view>
@@ -130,7 +132,7 @@
               <view class="tip">请输入站点名称</view>
               <view class="name-input">
                  <input ref="refInputName" :focus="true" placeholder="输入站点名称" :value="stationEdit.name"
                     @input="onInputStationName"></input>
                     @input="onInputStationName" />
                  <uni-icons class="clear" color="#ccc" type="clear" size="20" v-if="stationEdit.name"
                     @click="clickClearStationName"></uni-icons>
               </view>
@@ -209,15 +211,19 @@
            <view class="bottom-content" v-if="mapOperationStatus =='teaching'">
               <view class="tip">路径记录中...</view>
               <view v-if="mapOperationType =='public_teaching'">
                  <view>正在记录搬运车行进路径,可随时切换主路/支路示教,完成后点按钮以结束示教。在示教过程中可以添加站点。</view>
                  <view class="switch-type">
                  <!-- 主路/支路 -->
                  <view>正在记录搬运车行进路径,完成后点按钮以结束示教。在示教过程中可以添加站点。</view>
                  <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>
@@ -256,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"
@@ -345,7 +354,7 @@
                  <view class="img-button-group">
                     <view fill="none" class="button" @click.stop="clickStationDelete">
                        <text class="ico delete-outline"></text>
                        <view class="text"> 删除站点</view>
                        <view class="text"> 批量删除</view>
                     </view>
                     <view type="text" class="button" @click.stop="clickStationPostion">
                        <text class="ico edit-line"></text>
@@ -381,14 +390,48 @@
            </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>
</template>
<script src="./js/ctx.js" module="ctx" lang="renderjs"></script>
<script>
   import {
      ref
   } from "vue";
   import {
      showToast,
      showModal,
@@ -420,6 +463,9 @@
      delTeachingMode,
      delTeachingModeData,
      checkAgvLocationDistanceError,
      splitTeachingMode,
      updateSplitTeachingData,
      deleteSplitTeachingData
   } from "@/api/vehicle.js"
   export default {
      name: "PagesMap",
@@ -440,6 +486,7 @@
               list: []
            },
            sceneList: [],
            ctxDataStr: "[]",
            mapOperationType: "",
            mapOperationStatus: "",
@@ -471,7 +518,9 @@
            wallList: [],
            regionList: [],
            unlinked: false,
            showTeachingPathFlag: false,
            showTeachingPathFlag: true,
            curTeachingPathFlag: false,
            curTeachingPathTime: 0,
            curMapInfo: {
               proportion: 1,
               img_proportion: 1,
@@ -482,7 +531,9 @@
               img_x: 1,
               img_y: 1
            },
            positioningAgv: false
            positioningAgv: false,
            isPageVisible: true,
            destroyFlag: false,
         }
      },
      computed: {
@@ -539,10 +590,29 @@
      },
      onHide() {
         this.isPageVisible = false
      },
      onUnload() {
      async onUnload() {
         this.isPageVisible = false
         console.log("onUnload")
      },
      onBackPress() {
         this.isPageVisible = false
         if (this.destroyFlag)
            return false
         else {
            this.ctxDataStr = JSON.stringify([{
               method: "destroy",
            }])
            return true
         }
      },
      methods: {
         setData(obj) {
            let that = this;
@@ -572,6 +642,10 @@
                  this.mapOperationType = ''
                  const scene = this.sceneList[0]
                  this.changeMap(scene)
               } else {
                  uni.navigateBack({
                     delta: 1, //返回层数,2则上上页
                  })
               }
               this.refreshAgvPosition()
            } catch (ex) {
@@ -583,6 +657,10 @@
         },
         clickShowMenu() {
            // const list = [...this.sceneList]
            // for(let i =0; i < 20;i++){
            //    list.push("test" + i)
            // }
            this.menuPopup = {
               type: "scene",
               list: this.sceneList,
@@ -722,19 +800,27 @@
                  showModal("已记录的路径将会被删除。", "是否要退出示教?").then(async (res) => {
                     if (res) {
                        const listDataStr = []
                        if (this.mapOperationStatus == 'end' || this.mapOperationStatus ==
                           'save') {
                           try {
                              await delTeachingMode(this.vehicleIp, [this.teachingModeCur])
                              listDataStr.push({
                                 method: "remove_teaching_path",
                                 param: {
                                    name: this.teachingModeCur.name,
                                    mode: "Public"
                                 },
                              })
                           } catch (ex) {
                              showError(ex)
                           }
                        }
                        this.ctxDataStr = JSON.stringify([{
                        listDataStr.push({
                           method: "teaching_finish",
                        }])
                        })
                        this.ctxDataStr = JSON.stringify(listDataStr)
                        this.mapOperationType = ""
                     }
                  })
@@ -747,11 +833,7 @@
               }
            } else {
               // const eventChannel = this.getOpenerEventChannel();
               // eventChannel.emit('udapte_station', this.unlinked);
               // uni.navigateBack({
               //    delta: 1
               // })
               const eventChannel = this.getOpenerEventChannel();
               eventChannel.emit('check_connect', !this.unlinked);
               uni.navigateBack({
@@ -786,7 +868,7 @@
                  // this.mapOperationType = 'scene_create'
                  // this.opSceneType = 'add_name'
                  uni.navigateTo({
                     url: `/pages/map/scene?ip=${this.vehicleIp}`,
                     url: `/pages/map/scene?ip=${_this.vehicleIp}&opType=create`,
                     events: {
                        // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                        create_finish: function(data) {
@@ -802,15 +884,13 @@
                  this.clickDelete()
               }
            }
         },
         async loadAgvState() {
            try {
               const info = await getAgvState(this.vehicleIp)
               return info
            } catch (ex) {
               showError(ex)
               showToast(ex)
               return {}
            }
         },
@@ -819,7 +899,7 @@
               const paths = await getCurrentTeachingData(this.vehicleIp) || []
               return paths
            } catch (ex) {
               showError(ex)
               showToast(ex)
               return []
            }
         },
@@ -884,7 +964,6 @@
                  img_x: parseInt(infoMap.img_x) || 1,
                  img_y: parseInt(infoMap.img_y) || 1
               }
               // getApp().globalData.curScene = infoMap
               this.setData({
                  bgProgressPercent: 30,
                  bgLoading: infoMap.filedata ? true : false
@@ -909,13 +988,25 @@
                     param: stationLst
                  },
                  {
                     method: "show_teaching_path",
                     param: {
                        show: this.showTeachingPathFlag
                     }
                  },
                  {
                     method: "public_teaching_path",
                     param: this.teachingMode.Public || []
                     param: {
                        list: this.teachingMode.Public || [],
                        show: this.showTeachingPathFlag
                     }
                  },
                  {
                     method: "station_teaching_path",
                     param: this.teachingMode.Stations || []
                     param: {
                        list: this.teachingMode.Stations || [],
                        show: this.showTeachingPathFlag
                     }
                  },
                  {
@@ -939,7 +1030,14 @@
         receiveRenderData(param) {
            console.log('接收到视图层的数据:', param);
            if (param.method == "set_backgroud_progress") {
            if (param.method === "destroy_complete") {
               if (param.param) {
                  this.destroyFlag = true
                  uni.navigateBack({
                     delta: 1
                  })
               }
            } else if (param.method == "set_backgroud_progress") {
               if (param.type == "start") {
                  this.setData({
                     bgProgressPercent: 50,
@@ -975,6 +1073,9 @@
                  width: param.view?.width || 0,
                  height: param.view?.height || 0,
               }
               const angle = this.getStantardAngle(this.stationEdit.angle * 180 / Math.PI)
               this.angleSvg = `/static/images/angle${angle}.svg`
               this.mapOperationType = ""
               this.$refs.refPopupOperateStation.open("bottom")
@@ -1001,6 +1102,9 @@
                     const angle = this.getStantardAngle(this.stationEdit.angle * 180 / Math.PI)
                     this.angleSvg = `/static/images/angle${angle}.svg`
                     if (this.mapOperationType == "teaching_add_station") {
                        this.positioningAgv = true
                     }
                     this.clickStationPositonOk()
                  } else if (param.type == "edit_teaching") {
                     // console.log(param.type,JSON.stringify(param.data))
@@ -1048,7 +1152,7 @@
                     this.stationEdit.stationID = ""
                     this.mapOperationType = "public_teaching"
                     this.mapOperationStatus = "teaching"
                     this.positioningAgv = true
                  } else if (this.mapOperationType == "edit_station") {
                     this.mapOperationType = ""
                     this.mapOperationStatus = ""
@@ -1070,12 +1174,10 @@
                        param: true
                     }])
                  }
               }
            } else if (param.method == "select_teaching_path") {
               console.log("point", param.point)
               if (param.type == "station") {
                  this.selectTeachingMode = {
                     mode: "Stations",
                     name: param.data?.name || "",
@@ -1086,21 +1188,26 @@
               } 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") {
               this.positioningAgv = false
               if (this.mapOperationType == "public_teaching" &&
                  this.mapOperationStatus == "teaching") {
                  this.positioningAgv = true
               } else
                  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() {
            this.stationEdit = {
@@ -1129,6 +1236,7 @@
            this.mapOperationType = "edit_map"
         },
         clickExtendMap() {
            const _this = this
            uni.navigateTo({
               url: `/pages/map/scene?ip=${this.vehicleIp}&opType=extend&sceneId=${this.sceneId}`,
               events: {
@@ -1149,7 +1257,7 @@
            this.mapOperationStatus = ""
            this.teachingModeCur = {
               mode: "Public",
               main_road: 1,
               mode_type: 0,
            }
            this.positioningAgv = true
            this.mapOperationType = "public_teaching"
@@ -1170,9 +1278,8 @@
         },
         async loadSceneList() {
            try {
               uni.showLoading({
                  title: "加载场景中"
               })
               const _this = this
               const res = await getAllScene(this.vehicleIp) || []
               const list = res?.sceneList || []
@@ -1188,25 +1295,27 @@
                  //    sceneId: "",
                  //    navigationBarTitle: "地图"
                  // })
                  uni.navigateTo({
                     url: `/pages/map/scene?ip=${this.vehicleIp}&opType=create`,
                     events: {
                        // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                        create_finish: function(data) {
                           _this.onCreateSceneOk(data)
                        },
                     }
                  // uni.navigateTo({
                  //    url: `/pages/map/scene?ip=${this.vehicleIp}`,
                  //    events: {
                  //       // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                  //       create_finish: function(data) {
                  //          _this.onCreateSceneOk(data)
                  //       },
                  //    }
                  // })
                  uni.navigateBack({
                     delta: 1, //返回层数,2则上上页
                  })
                  return
               }
            } catch (ex) {
               showError(ex)
            } finally {
               uni.hideLoading()
            }
         },
         clickDelete() {
            const _this = this
            showModal(`删除场景[${this.sceneId}]会把场景对应的地图任务信息都会删除,是否确认删除?`, "删除场景").then(async (res) => {
               if (res) {
                  try {
@@ -1218,6 +1327,15 @@
                     await this.loadSceneList()
                     if (this.sceneList.length > 0)
                        this.changeMap(this.sceneList[0])
                     // else {
                     //    _this.mapOperationType = ""
                     //    setTimeout(() => {
                     //       uni.navigateBack({
                     //          delta: 1, //返回层数,2则上上页
                     //       })
                     //    }, 500)
                     // }
                  } catch (ex) {
                     showError(ex)
                  } finally {
@@ -1387,14 +1505,23 @@
                  showToast("场景名称不能为空!")
                  return
               }
               console.log(name, this.sceneId)
               // console.log(name, this.sceneId)
               if (name == this.sceneId) {
                  showToast("场景名称未变化!")
                  return
               }
               const curIndex = this.sceneList.findIndex((param) => param == this.sceneId)
               this.mapOperationType = ""
               await updateScene(this.vehicleIp, this.sceneId, name)
               this.sceneId = name
               if (curIndex > -1) {
                  this.sceneList[curIndex] = name
               }
               this.setData({
                  navigationBarTitle: name
               })
               showToast("场景重命名成功!")
            } catch (ex) {
               this.mapOperationType = "edit_scene_name"
@@ -1427,7 +1554,27 @@
            this.mapOperationType = ""
         },
         clickStationDelete() {
            this.stationDelete(this.stationEdit)
            const _this = this
            uni.navigateTo({
               url: `/pages/station/delete?ip=${ this.vehicleIp}`,
               events: {
                  // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                  delete_finish: function(data) {
                     console.log(data)
                     const list = data.map((a) => {
                        return {
                           stationID: a
                        }
                     })
                     _this.ctxDataStr = JSON.stringify([{
                        method: "remove_station",
                        param: list
                     }])
                  }
               }
            })
            //this.stationDelete(this.stationEdit)
            // const _this = this
            // showModal("该站点已绑定任务,删除站点后绑定的任务会停止并删除", "是否确认删除?").then((res) => {
            //    if (res) {
@@ -1726,10 +1873,8 @@
            return resAngle
         },
         touchAngleChange(e) {
            let angle = 0
            const ptX = e.touches[0].clientX
            const offX = ptX // ptX - e.target.offsetLeft
@@ -1832,7 +1977,7 @@
            try {
               const {
                  data
               } = await getTeachingMode(this.vehicleIp)
               } = await splitTeachingMode(this.vehicleIp)
               return data || {
                  Public: [],
                  Stations: []
@@ -1846,26 +1991,35 @@
               }
            }
         },
         async reloadTeachingMode() {
         async reloadTeachingMode(finish) {
            try {
               this.teachingMode = await this.loadTeachingMode()
               this.ctxDataStr = JSON.stringify([{
               const list = [{
                     method: "clear_teaching_path",
                  },
                  {
                     method: "public_teaching_path",
                     param: this.teachingMode.Public || []
                     param: {
                        list: this.teachingMode.Public || [],
                        show: this.showTeachingPathFlag
                     }
                  },
                  {
                     method: "station_teaching_path",
                     param: this.teachingMode.Stations || []
                  }, {
                     method: "show_teaching_path",
                     param: {
                        list: this.teachingMode.Stations || [],
                        show: this.showTeachingPathFlag
                     }
                  }
               ])
               ]
               if (finish) {
                  list.push({
                     method: "teaching_finish",
                  })
               }
               this.ctxDataStr = JSON.stringify(list)
            } catch (ex) {
               showError(ex)
@@ -1921,44 +2075,165 @@
                     method: "update_agv_state",
                     param: agv
                  }]
                  // if (this.mapOperationType === "public_teaching" && this.mapOperationStatus ===
                  //    "teaching") {
                  const list = await this.loadCurrentTeachingData()
                  if (this.mapOperationType === "public_teaching" && this.mapOperationStatus ===
                     "teaching") {
                     const list = await this.loadCurrentTeachingData()
                     listCtrData.push({
                        method: "update_current_teaching",
                        param: {
                           main_road: this.teachingModeCur.main_road,
                           pos_list: list
                  listCtrData.push({
                     method: "update_current_teaching",
                     param: {
                        main_road: 1, //this.teachingModeCur.main_road,
                        pos_list: list
                     }
                  })
                  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 || []
                        const stationOld = this.teachingMode.Stations || []
                        const publicNew = teaching.Public || []
                        const stationNew = teaching.Stations || []
                        const publicAdd = []
                        const stationAdd = []
                        for (let i in publicNew) {
                           const item = publicNew[i]
                           const curIndex = publicOld.findIndex((a) => a.name == item.name && a.edge_name == item.edge_name )
                           if (curIndex < 0) {
                              publicAdd.push(item)
                              publicOld.push(item)
                           }
                        }
                        for (let i in stationNew) {
                           const item = stationNew[i]
                           const curIndex = stationOld.findIndex((a) => a.name == item.name)
                           if (curIndex < 0) {
                              stationAdd.push(item)
                              stationOld.push(item)
                           }
                        }
                        this.teachingMode.Public = publicOld
                        this.teachingMode.Stations = stationOld
                        if (publicAdd.length > 0) {
                           listCtrData.push({
                              method: "public_teaching_path",
                              param: {
                                 list: publicAdd,
                                 show: this.showTeachingPathFlag
                              }
                           })
                        }
                        if (stationAdd.length > 0) {
                           listCtrData.push({
                              method: "station_teaching_path",
                              param: {
                                 list: stationAdd,
                                 show: this.showTeachingPathFlag
                              }
                           })
                        }
                        const listStationCtxData = await this.getRefreshStationCtxData() || []
                        if (listStationCtxData.length > 0) {
                           listCtrData.push(...listStationCtxData)
                        }
                     }
                  }
                  // }
                  if (this.positioningAgv) {
                     listCtrData.push({
                        method: "move_pt_visible",
                        param: {
                           x: agv.x,
                           y: agv.y,
                           width:80,
                           height:80,
                        }
                     })
                     if (this.curTeachingPathFlag) {
                        listCtrData.push({
                           method: "move_pt_center",
                           param: {
                              x: agv.x,
                              y: agv.y,
                           }
                        })
                     } else {
                        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);
               //setTimeout(this.refreshAgvPosition, 1000);
            } catch (ex) {
               showError(ex).then((res) => {
                  setTimeout(this.refreshAgvPosition, 1000);
               })
               // showError(ex).then((res) => {
               // })
               showToast(ex)
            } finally {
               // 无论成功失败,1 秒后再来
               setTimeout(this.refreshAgvPosition, 1000);
            }
         },
         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) => {
@@ -1986,7 +2261,6 @@
               uni.hideLoading()
            }
         },
         async clickTeachingStart() {
            const _this = this
@@ -2024,6 +2298,16 @@
                        this.loading = true
                        await delTeachingMode(_this.vehicleIp, [_this.teachingModeCur])
                        _this.mapOperationStatus = ""
                        const listDataStr = []
                        listDataStr.push({
                           method: "remove_teaching_path",
                           param: {
                              name: _this.teachingModeCur.name,
                              mode: "Public"
                           },
                        })
                        _this.ctxDataStr = JSON.stringify(listDataStr)
                     } catch (ex) {
                        showError(ex)
@@ -2032,8 +2316,7 @@
                     }
                  } else {
                     _this.mapOperationStatus =
                        "save"
                     _this.mapOperationStatus = "save"
                  }
               })
@@ -2049,10 +2332,8 @@
         },
         clickTeachingFinish() {
            this.mapOperationType = ""
            this.ctxDataStr = JSON.stringify([{
               method: "teaching_finish",
            }])
            this.reloadTeachingMode()
            //this.reloadTeachingMode(true)
         },
         async teachingStart(mode) {
@@ -2082,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(
@@ -2119,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 {
@@ -2130,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(
                        "已将该路段路径保存为主路示教路线"
                     )
@@ -2155,28 +2445,28 @@
                     )
                  if (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]]
                        } ])
                     }
                  const {
                     data
                  } = await splitTeachingMode(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: {
                           list: [publicList[curIndex]],
                           show: true
                        }
                     }])
                  }
*/
               } else {
                  this.teachingModeCur
                     .main_road =
                     val
                  this.teachingModeCur.mode_type = val
               }
            } catch (ex) {
@@ -2194,30 +2484,65 @@
         },
         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) {
            try {
               uni.showLoading({
                  title: "删除场景中"
                  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)
@@ -2228,9 +2553,10 @@
         async removeTeachingModeData(data) {
            try {
               uni.showLoading({
                  title: "删除场景数据中"
                  title: "删除示教数据中"
               })
               await delTeachingModeData(this.vehicleIp, data)
               showToast("删除示教成功")
               this.reloadTeachingMode()
            } catch (ex) {
               showError(ex)
@@ -2674,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;
               }
            }
@@ -2701,10 +3029,21 @@
         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;
         width: 300rpx;
         max-height: 50vh;
         overflow: auto;
         align-items: center;
         justify-content: center;
         flex-direction: column;