From fb026e6052b4d843d327312db398cf791ac57ab9 Mon Sep 17 00:00:00 2001
From: cyy <cuiqian2004@163.com>
Date: 星期日, 28 九月 2025 22:43:29 +0800
Subject: [PATCH] test
---
pages/map/index.vue | 583 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 393 insertions(+), 190 deletions(-)
diff --git a/pages/map/index.vue b/pages/map/index.vue
index 98e8b78..9240203 100644
--- a/pages/map/index.vue
+++ b/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,8 +211,8 @@
<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>姝e湪璁板綍鎼繍杞﹁杩涜矾寰勶紝瀹屾垚鍚庣偣鎸夐挳浠ョ粨鏉熺ず鏁欍�鍦ㄧず鏁欒繃绋嬩腑鍙互娣诲姞绔欑偣銆�/view>
+ <!-- <view class="switch-type">鍙殢鏃跺垏鎹富璺�鏀矾绀烘暀锛� <view class="switch-button-group">
<view class="switch-button"
:class="teachingModeCur.main_road ==1?'switch-button-checked':''"
@@ -219,7 +221,7 @@
:class="teachingModeCur.main_road ==0?'switch-button-checked':''"
@click="onTeachingModeMainRoad(0)">鏀矾绀烘暀</view>
</view>
- </view>
+ </view> -->
</view>
<view v-else>
@@ -345,7 +347,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>
@@ -386,13 +388,16 @@
</view>
</template>
<script src="./js/ctx.js" module="ctx" lang="renderjs"></script>
-
-
<script>
+ import {
+ ref
+ } from "vue";
import {
showToast,
showModal,
session,
+ showError,
+ showInfo
} from "@/comm/utils.js"
// import OIFabric from "@/components/oi-fabric/index.vue"
import {
@@ -438,6 +443,7 @@
list: []
},
sceneList: [],
+
ctxDataStr: "[]",
mapOperationType: "",
mapOperationStatus: "",
@@ -469,7 +475,8 @@
wallList: [],
regionList: [],
unlinked: false,
- showTeachingPathFlag: false,
+ showTeachingPathFlag: true,
+ curTeachingPathFlag: false,
curMapInfo: {
proportion: 1,
img_proportion: 1,
@@ -480,6 +487,9 @@
img_x: 1,
img_y: 1
},
+ positioningAgv: false,
+ isPageVisible: true,
+ destroyFlag: false,
}
},
computed: {
@@ -536,10 +546,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;
@@ -569,17 +598,25 @@
this.mapOperationType = ''
const scene = this.sceneList[0]
this.changeMap(scene)
+ } else {
+ uni.navigateBack({
+ delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
+ })
}
this.refreshAgvPosition()
} catch (ex) {
this.setData({
unlinked: true
})
- this.showError(ex)
+ showError(ex)
}
},
clickShowMenu() {
+ // const list = [...this.sceneList]
+ // for(let i =0; i < 20;i++){
+ // list.push("test" + i)
+ // }
this.menuPopup = {
type: "scene",
list: this.sceneList,
@@ -719,18 +756,26 @@
showModal("宸茶褰曠殑璺緞灏嗕細琚垹闄ゃ�", "鏄惁瑕侀�鍑虹ず鏁欙紵").then(async (res) => {
if (res) {
- if (mapOperationStatus == 'end' || mapOperationStatus == 'save') {
+ const listDataStr = []
+ if (this.mapOperationStatus == 'end' || this.mapOperationStatus ==
+ 'save') {
try {
- await delTeachingMode(this.vehicleIp, [_this.teachingModeCur])
+ await delTeachingMode(this.vehicleIp, [this.teachingModeCur])
+ listDataStr.push({
+ method: "remove_teaching_path",
+ param: {
+ name: this.teachingModeCur.name,
+ mode: "Public"
+ },
+ })
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
-
}
- this.ctxDataStr = JSON.stringify([{
+ listDataStr.push({
method: "teaching_finish",
- }])
-
+ })
+ this.ctxDataStr = JSON.stringify(listDataStr)
this.mapOperationType = ""
}
})
@@ -743,11 +788,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({
@@ -782,7 +823,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) {
@@ -798,15 +839,13 @@
this.clickDelete()
}
}
-
-
},
async loadAgvState() {
try {
const info = await getAgvState(this.vehicleIp)
return info
} catch (ex) {
- this.showError(ex)
+ showToast(ex)
return {}
}
},
@@ -815,7 +854,7 @@
const paths = await getCurrentTeachingData(this.vehicleIp) || []
return paths
} catch (ex) {
- this.showError(ex)
+ showToast(ex)
return []
}
},
@@ -825,7 +864,7 @@
const info = await stations(this.vehicleIp)
return info.station_list || []
} catch (ex) {
- this.showError(ex)
+ showError(ex)
return []
}
},
@@ -834,7 +873,7 @@
const info = await getMapUrl(this.vehicleIp, id)
return info
} catch (ex) {
- this.showError(ex)
+ showError(ex)
return {}
}
},
@@ -864,22 +903,22 @@
try {
this.setData({
bgProgressPercent: 0,
+ bgLoading: true
})
const infoAgv = await this.loadAgvState()
const stationLst = await this.loadStations()
const infoMap = await this.loadMapInfo(id)
this.curMapInfo = {
- proportion: infoMap.proportion || 1,
- img_proportion: infoMap.img_proportion || 1,
- max_x: infoMap.max_x || 1,
- max_y: infoMap.max_y || 1,
- min_x: infoMap.min_x || 0,
- min_y: infoMap.min_y || 0,
- img_x: infoMap.img_x || 1,
- img_y: infoMap.img_y || 1
+ proportion: parseInt(infoMap.proportion) || 1,
+ img_proportion: parseInt(infoMap.img_proportion) || 1,
+ max_x: parseInt(infoMap.max_x) || 1,
+ max_y: parseInt(infoMap.max_y) || 1,
+ min_x: parseInt(infoMap.min_x) || 0,
+ min_y: parseInt(infoMap.min_y) || 0,
+ 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
@@ -904,36 +943,56 @@
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
+ }
},
{
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: infoAgv.x,
y: infoAgv.y
}
}
])
+ this.positioningAgv = true
this.mapShowAgv = true
} catch (ex) {
this.setData({
bgProgressPercent: 0,
bgLoading: false
})
- this.showError(ex)
+ showError(ex)
}
},
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,
@@ -969,6 +1028,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")
@@ -995,6 +1057,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))
@@ -1042,7 +1107,7 @@
this.stationEdit.stationID = ""
this.mapOperationType = "public_teaching"
this.mapOperationStatus = "teaching"
-
+ this.positioningAgv = true
} else if (this.mapOperationType == "edit_station") {
this.mapOperationType = ""
this.mapOperationStatus = ""
@@ -1064,12 +1129,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 || "",
@@ -1084,10 +1147,18 @@
point: param.point
}
}
-
this.$refs.refPopupOperateTeaching.open("bottom")
+ } else if (param.method == "cancel_positioning_agv") {
+ 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 = {
@@ -1116,6 +1187,7 @@
this.mapOperationType = "edit_map"
},
clickExtendMap() {
+ const _this = this
uni.navigateTo({
url: `/pages/map/scene?ip=${this.vehicleIp}&opType=extend&sceneId=${this.sceneId}`,
events: {
@@ -1138,11 +1210,9 @@
mode: "Public",
main_road: 1,
}
+ this.positioningAgv = true
this.mapOperationType = "public_teaching"
this.ctxDataStr = JSON.stringify([{
- method: "set_selectable",
- param: false,
- }, {
method: "public_teaching",
}])
@@ -1159,9 +1229,8 @@
},
async loadSceneList() {
try {
- uni.showLoading({
- title: "鍔犺浇鍦烘櫙涓�
- })
+
+
const _this = this
const res = await getAllScene(this.vehicleIp) || []
const list = res?.sceneList || []
@@ -1177,25 +1246,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, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
})
return
}
} catch (ex) {
- this.showError(ex)
- } finally {
- uni.hideLoading()
- }
+ showError(ex)
+ }
},
clickDelete() {
+ const _this = this
showModal(`鍒犻櫎鍦烘櫙[${this.sceneId}]浼氭妸鍦烘櫙瀵瑰簲鐨勫湴鍥句换鍔′俊鎭兘浼氬垹闄わ紝鏄惁纭鍒犻櫎锛焋, "鍒犻櫎鍦烘櫙").then(async (res) => {
if (res) {
try {
@@ -1207,8 +1278,17 @@
await this.loadSceneList()
if (this.sceneList.length > 0)
this.changeMap(this.sceneList[0])
+ // else {
+ // _this.mapOperationType = ""
+ // setTimeout(() => {
+ // uni.navigateBack({
+ // delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
+ // })
+ // }, 500)
+
+ // }
} catch (ex) {
- this.showError(ex)
+ showError(ex)
} finally {
uni.hideLoading()
}
@@ -1263,7 +1343,7 @@
param: [this.regionEdit]
},
{
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: agv.x,
y: agv.y
@@ -1272,7 +1352,7 @@
])
}
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
async clickPlanProhibitionRegion() {
@@ -1309,7 +1389,7 @@
param: [this.regionEdit]
},
{
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: agv.x,
y: agv.y
@@ -1318,7 +1398,7 @@
])
}
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
@@ -1350,7 +1430,7 @@
param: [this.wallEdit]
},
{
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: agv.x,
y: agv.y
@@ -1358,7 +1438,7 @@
}
])
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
@@ -1376,18 +1456,27 @@
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"
- this.showError(ex)
+ showError(ex)
} finally {
uni.hideLoading()
this.loading = false
@@ -1417,11 +1506,32 @@
},
clickStationDelete() {
const _this = this
- showModal("璇ョ珯鐐瑰凡缁戝畾浠诲姟锛屽垹闄ょ珯鐐瑰悗缁戝畾鐨勪换鍔′細鍋滄骞跺垹闄�, "鏄惁纭鍒犻櫎锛�).then((res) => {
- if (res) {
- this.stationDelete(this.stationEdit)
+ 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) {
+
+ // }
+ // })
},
async stationAdd(item) {
try {
@@ -1440,7 +1550,7 @@
} catch (ex) {
- this.showError(ex)
+ showError(ex)
} finally {
uni.hideLoading()
}
@@ -1463,7 +1573,7 @@
}
} catch (ex) {
- this.showError(ex)
+ showError(ex)
} finally {
uni.hideLoading()
}
@@ -1477,6 +1587,7 @@
this.stationAdd(this.stationEdit)
this.mapOperationType = "public_teaching"
this.mapOperationStatus = "teaching"
+ this.positioningAgv = true
return
} else if (this.mapOperationType == "edit_station") {
this.stationUpdate(this.stationEdit)
@@ -1487,7 +1598,7 @@
}])
this.mapOperationType = ''
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
async stationDelete(item) {
@@ -1514,7 +1625,7 @@
}])
} catch (ex) {
- this.showError(ex)
+ showError(ex)
} finally {
uni.hideLoading()
}
@@ -1559,14 +1670,14 @@
},
async clickStationNameOK() {
try {
- this.loading = true
+
const name = this.stationEdit.name.trim()
if (!name) {
showToast("绔欑偣鍚嶇О杩樻湭杈撳叆")
return
}
- if (this.mapOperationType == 'add_station' || this
- .mapOperationType == "teaching_add_station") {
+ this.loading = true
+ if (this.mapOperationType == 'add_station' || this.mapOperationType == "teaching_add_station") {
const agv = await this.loadAgvState()
this.stationEdit = {
stationID: this.getMaxStationNo + 1,
@@ -1589,7 +1700,7 @@
method: "edit_station_pos",
param: this.stationEdit
}, {
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: agv.x,
y: agv.y
@@ -1613,7 +1724,7 @@
}
} catch (ex) {
- this.showError(ex)
+ showError(ex)
} finally {
this.loading = false
}
@@ -1639,7 +1750,7 @@
method: "update_station",
param: [this.stationEdit]
}, {
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: this.stationEdit.x,
y: this.stationEdit.y
@@ -1654,7 +1765,7 @@
method: "update_station",
param: [this.stationEdit]
}, {
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: this.stationEdit.x,
y: this.stationEdit.y
@@ -1667,7 +1778,7 @@
method: "update_station",
param: [this.stationEdit]
}, {
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: this.stationEdit.x,
y: this.stationEdit.y
@@ -1680,7 +1791,7 @@
method: "update_station",
param: [this.stationEdit]
}, {
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: this.stationEdit.x,
y: this.stationEdit.y
@@ -1713,10 +1824,8 @@
return resAngle
},
-
touchAngleChange(e) {
let angle = 0
-
const ptX = e.touches[0].clientX
const offX = ptX // ptX - e.target.offsetLeft
@@ -1766,19 +1875,20 @@
async clickVehiclePosition() {
try {
+ this.positioningAgv = true
const infoAgv = await this.loadAgvState()
this.ctxDataStr = JSON.stringify([{
method: "update_agv_state",
param: infoAgv
}, {
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: infoAgv.x,
y: infoAgv.y
}
}])
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
async clickPositionStation() {
@@ -1801,7 +1911,7 @@
param: [this.stationEdit]
},
{
- method: "move_canvas",
+ method: "move_pt_center",
param: {
x: infoAgv.x,
y: infoAgv.y
@@ -1811,7 +1921,7 @@
])
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
async loadTeachingMode() {
@@ -1825,33 +1935,45 @@
}
} catch (ex) {
- this.showError(ex)
+ showError(ex)
return {
Public: [],
Stations: []
}
}
},
- 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) {
- this.showError(ex)
+ showError(ex)
}
},
@@ -1893,34 +2015,118 @@
}
])
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
async refreshAgvPosition() {
try {
if (this.isPageVisible && this.mapShowAgv) {
const agv = await this.loadAgvState()
-
const listCtrData = [{
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.curTeachingPathFlag = true
+ } else {
+ if (this.curTeachingPathFlag) {
+ this.curTeachingPathFlag = false
+ 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)
+ console.log(curIndex, item)
+ 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
+ }
+ })
+ }
+ }
}
+
+ // }
+
+ if (this.positioningAgv) {
+ 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);
} catch (ex) {
- this.showError(ex)
+ // showError(ex).then((res) => {
+
+ // })
+ showToast(ex)
} finally {
// 鏃犺鎴愬姛澶辫触锛� 绉掑悗鍐嶆潵
setTimeout(this.refreshAgvPosition, 1000);
@@ -1946,17 +2152,15 @@
uni.showLoading({
title: "绀烘暀缁撴潫"
})
- await teachingModeFlag(this.vehicleIp,
- teachingMode)
+ await teachingModeFlag(this.vehicleIp, teachingMode)
this.mapOperationStatus = "end"
} catch (ex) {
- this.showError(ex)
+ showError(ex)
} finally {
uni.hideLoading()
}
},
-
async clickTeachingStart() {
const _this = this
@@ -1969,7 +2173,7 @@
await _this.teachingStart("Public")
} catch (ex) {
- this.showError(ex)
+ showError(ex)
} finally {
this.loading = false
uni.hideLoading()
@@ -1994,16 +2198,25 @@
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) {
- this.showError(ex)
+ showError(ex)
} finally {
this.loading = false
}
} else {
- _this.mapOperationStatus =
- "save"
+ _this.mapOperationStatus = "save"
}
})
@@ -2013,16 +2226,14 @@
this.mapOperationStatus = "save"
try {} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
clickTeachingFinish() {
this.mapOperationType = ""
- this.ctxDataStr = JSON.stringify([{
- method: "teaching_finish",
- }])
- this.reloadTeachingMode()
+
+ //this.reloadTeachingMode(true)
},
async teachingStart(mode) {
@@ -2071,7 +2282,7 @@
}
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
@@ -2094,41 +2305,27 @@
.teachingModeCur
)
} catch (ex) {
- this.showError(ex)
+ showError(ex)
} finally {
this.loading = false
}
},
- async onTeachingModeMainRoad(
- val) {
+ async onTeachingModeMainRoad(val) {
try {
- if (this
- .mapOperationStatus
- ) {
+ if (this.mapOperationStatus) {
- if (this
- .teachingModeCur
- .main_road ==
- val) {
+ if (this.teachingModeCur.main_road == val) {
return
}
- this.teachingModeCur
- .main_road =
- val
- this.teachingModeCur
- .teaching_flag =
- 1
- this.teachingModeCur
- .mode =
- "Public"
- const res =
- await teachingModeFlag(
- this
- .vehicleIp,
- this
- .teachingModeCur
- )
+ this.teachingModeCur.teaching_flag = 0
+ const oldName = this.teachingModeCur.name
+ await teachingModeFlag(this.vehicleIp, this.teachingModeCur)
+ this.teachingModeCur.main_road = val
+ this.teachingModeCur.teaching_flag = 1
+ this.teachingModeCur.mode = "Public"
+ this.teachingModeCur.name = ""
+ const res = await teachingModeFlag(this.vehicleIp, this.teachingModeCur)
if (val == 0)
showToast(
"宸插皢璇ヨ矾娈佃矾寰勪繚瀛樹负涓昏矾绀烘暀璺嚎"
@@ -2138,10 +2335,27 @@
"宸插皢璇ヨ矾娈佃矾寰勪繚瀛樹负鏀矾绀烘暀璺嚎"
)
if (res?.name)
- this
- .teachingModeCur
- .name = 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: {
+ list: [publicList[curIndex]],
+ show: true
+ }
+ }])
+
+ }
+
+
} else {
this.teachingModeCur
.main_road =
@@ -2149,7 +2363,7 @@
}
} catch (ex) {
- this.showError(ex)
+ showError(ex)
}
},
clickTeachingDelete() {
@@ -2178,7 +2392,7 @@
async removeTeachingMode(item) {
try {
uni.showLoading({
- title: "鍒犻櫎鍦烘櫙涓�
+ title: "鍒犻櫎绀烘暀涓�
})
await delTeachingMode(this.vehicleIp, [item])
this.ctxDataStr =
@@ -2188,7 +2402,7 @@
param: item,
}])
} catch (ex) {
- this.showError(
+ showError(
ex)
} finally {
uni.hideLoading()
@@ -2197,29 +2411,16 @@
async removeTeachingModeData(data) {
try {
uni.showLoading({
- title: "鍒犻櫎鍦烘櫙鏁版嵁涓�
+ title: "鍒犻櫎绀烘暀鏁版嵁涓�
})
await delTeachingModeData(this.vehicleIp, data)
this.reloadTeachingMode()
} catch (ex) {
- this.showError(
- ex)
+ showError(ex)
} finally {
uni.hideLoading()
}
},
-
- showError(ex) {
- let exStr = JSON.stringify(ex)
- if (exStr == "{}")
- exStr = ex
- let tip = typeof ex.msg == "string" ? ex.msg : typeof ex.errMsg == "string" ? ex.errMsg : exStr
- showModal(tip,
- "閿欒",
- false,
- "纭畾")
- },
-
}
}
@@ -2687,6 +2888,8 @@
margin-top: 140rpx;
margin-left: 225rpx;
width: 300rpx;
+ max-height: 50vh;
+ overflow: auto;
align-items: center;
justify-content: center;
flex-direction: column;
--
Gitblit v1.9.1