cuiqian2004
2025-10-11 bcfb05f5e7782ef23e4deb1b38a1ca4b4085181a
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>正在记录搬运车行进路径,完成后点按钮以结束示教。在示教过程中可以添加站点。</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;
               }
            }