| | |
| | | <view class="position-site"> |
| | | <a-button type="ghost" class="button" @click="clickPositionStation"> |
| | | <text class="ico my-location-rounded" /> |
| | | <text class="text">获取搬运车位置和朝向</text> |
| | | <text class="text">{{translate("obtain_positon_and_orientation_of_vehicle")}}</text> |
| | | </a-button> |
| | | </view> |
| | | </view> |
| | |
| | | @touchcancel="onTouchCancelStation"> |
| | | <view class="item-title">{{item.name}}</view> |
| | | <view class="item-text"> |
| | | 角度:{{Math.round(item.angle *180/3.14)}},坐标({{Math.round(Number(item.x)*100)/100}},{{Math.round(Number(item.y)*100)/100}}) |
| | | {{translate("angle")}}:{{Math.round(item.angle *180/3.14)}},{{translate("coordinates")}}({{Math.round(Number(item.x)*100)/100}},{{Math.round(Number(item.y)*100)/100}}) |
| | | </view> |
| | | <template v-slot:right> |
| | | <view class="btn-del" @click="clickDelStation(item)">删除</view> |
| | | <view class="btn-del" @click="clickDelStation(item)">{{translate("delete")}}</view> |
| | | </template> |
| | | </uni-swipe-action-item> |
| | | </uni-swipe-action> |
| | | </view> |
| | | <view class="list-no-content" v-else> |
| | | <uni-icons color="#ccc" type="info" size="128"></uni-icons> |
| | | <view class="space">还没有站点</view> |
| | | <view class="space">{{translate("no_station")}}</view> |
| | | </view> |
| | | <view class="position-add" v-if="opStationType ==''" @click="clickAddStation" @touchstart='btnAddTouchStart' |
| | | @touchmove='btnAddTouchMove' |
| | |
| | | @click="clickClearName"></uni-icons> |
| | | </view> |
| | | <view class="text-button-group"> |
| | | <a-button type="ghost" class="button" @click="clickNameCancel">取消</a-button> |
| | | <a-button type="primary" class="button" @click="clickNameOK">确定</a-button> |
| | | <a-button type="ghost" class="button" @click="clickNameCancel">{{translate('cancel')}}</a-button> |
| | | <a-button type="primary" class="button" @click="clickNameOK">{{translate('ok')}}</a-button> |
| | | </view> |
| | | </view> |
| | | <view class="bottom-content" v-else-if=" opStationType =='edit_pos'"> |
| | |
| | | this.onlyAdd = option.isAdd ? true : false |
| | | |
| | | uni.setNavigationBarTitle({ |
| | | title: "站点列表" |
| | | title: this.translate("station_list") |
| | | }) |
| | | uni.getSystemInfo({ |
| | | success(e) { |
| | |
| | | if (this.onlyAdd) { |
| | | this.opStationType = "edit_name" |
| | | uni.setNavigationBarTitle({ |
| | | title: "添加站点" |
| | | title: this.translate("add_station") |
| | | }) |
| | | } |
| | | |
| | |
| | | if (this.opStationType == "edit_name" || this.opStationType == "edit_pos") { |
| | | this.opStationType = "" |
| | | uni.setNavigationBarTitle({ |
| | | title: "站点列表" |
| | | title: this.translate("station_list") |
| | | }) |
| | | this.$refs.refPopupOperateStation.open("bottom") |
| | | |
| | |
| | | |
| | | } catch (ex) { |
| | | |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | async loadAgvState() { |
| | |
| | | const info = await getAgvState(this.ip) |
| | | return info |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | return {} |
| | | } |
| | | }, |
| | |
| | | const info = await stations(this.ip) |
| | | return info.station_list || [] |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | return [] |
| | | } |
| | | }, |
| | |
| | | } |
| | | this.opStationType = "edit_name" |
| | | uni.setNavigationBarTitle({ |
| | | title: "添加站点" |
| | | title: this.translate("add_station") |
| | | }) |
| | | |
| | | }, |
| | |
| | | this.pressStationTimer = null; |
| | | }, |
| | | clickDelStation(item) { |
| | | showModal("确认删除站点", "警告",true,"确定","取消").then((res) => { |
| | | showModal({ |
| | | title: this.translate("ask_confirm_remove"), |
| | | content: `${this.translate('delete_selected_station')}`, |
| | | confirmText: this.translate('remove'), |
| | | cancelText: this.translate('cancel'), |
| | | }).then((res) => { |
| | | if (res) { |
| | | this.deleteStation(item) |
| | | } |
| | |
| | | } |
| | | |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | |
| | | }, |
| | | clickStationDelete() { |
| | | const _this = this |
| | | showModal("确认删除站点", "警告",true,"确定","取消").then((res) => { |
| | | showModal({ |
| | | title: this.translate("ask_confirm_remove"), |
| | | content: `${this.translate('delete_selected_station')}`, |
| | | confirmText: this.translate('remove'), |
| | | cancelText: this.translate('cancel'), |
| | | }).then((res) => { |
| | | if (res) { |
| | | _this.deleteStation(this.stationEdit) |
| | | _this.$refs.refPopupOperateStation.close() |
| | |
| | | |
| | | this.opStationType = "edit_pos" |
| | | uni.setNavigationBarTitle({ |
| | | title: "调整站点位置和朝向" |
| | | title: this.translate("adjust_position_orientation") |
| | | }) |
| | | this.$refs.refPopupOperateStation.close() |
| | | }, |
| | |
| | | this.isEdit = true |
| | | this.opStationType = "edit_name" |
| | | uni.setNavigationBarTitle({ |
| | | title: "站点重命名" |
| | | title: this.translate("rename") |
| | | }) |
| | | this.$refs.refPopupOperateStation.close() |
| | | }, |
| | |
| | | |
| | | |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | async stationUpdate(item) { |
| | |
| | | } |
| | | |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | |
| | |
| | | if (this.isEdit) { |
| | | this.opStationType = "" |
| | | uni.setNavigationBarTitle({ |
| | | title: "站点列表" |
| | | title: this.translate("station_list") |
| | | }) |
| | | this.$refs.refPopupOperateStation.open("bottom") |
| | | } else { |
| | |
| | | try { |
| | | const name = this.stationEdit.name.trim() |
| | | if (!name) { |
| | | showToast("站点名称还未输入") |
| | | showToast(this.translate("input_station_name")) |
| | | return |
| | | } |
| | | if (this.isEdit) { |
| | |
| | | await this.stationUpdate(this.stationEdit) |
| | | this.opStationType = "" |
| | | uni.setNavigationBarTitle({ |
| | | title: "站点列表" |
| | | title: this.translate("station_list") |
| | | }) |
| | | this.$refs.refPopupOperateStation.open("bottom") |
| | | } else { |
| | |
| | | } |
| | | |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | |
| | | }, |
| | |
| | | await this.stationUpdate(this.stationEdit) |
| | | this.opStationType = "" |
| | | uni.setNavigationBarTitle({ |
| | | title: "站点列表" |
| | | title: this.translate("station_list") |
| | | }) |
| | | this.$refs.refPopupOperateStation.open("bottom") |
| | | } else { |
| | |
| | | } |
| | | } catch (ex) { |
| | | |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | clickClearName() { |
| | |
| | | else |
| | | this.showClearName = false |
| | | }, |
| | | validateNumber(input) { |
| | | // 常用正则模式 |
| | | const patterns = { |
| | | integer: /^-?\d+$/, // 整数,包括负数 [citation:6] |
| | | positiveInt: /^[1-9]\d*$/, // 正整数 [citation:7] |
| | | decimal: /^-?\d*\.?\d+$/, // 小数 (支持像 ".1" 这样的格式) |
| | | decimalFixed: /^-?\d*\.?\d{0,3}$/, // 最多两位小数 [citation:5][citation:8] |
| | | }; |
| | | // 选择需要的模式进行测试,例如使用 decimal |
| | | return patterns.decimalFixed.test(input); |
| | | }, |
| | | onInputX(event) { |
| | | const strictRegex = /^[-+]?(\d+\.?\d*|\.\d+)$/; |
| | | let num = event.detail.value |
| | | if (!strictRegex.test(num)) { |
| | | showToast("输入内容只能包含数字、正负号和小数点") |
| | | if (!this.validateNumber(num)) { |
| | | showToast(this.translate("input_content_only_numbers_and_signs_and_decimal")) |
| | | return |
| | | } else { |
| | | if (Math.round(Number(num)) === Number(num)) { |
| | | if (!Number.isSafeInteger(Number(num))) { |
| | | showToast("输入数字超出数值安全范围") |
| | | } |
| | | } else { |
| | | if (!Number.isSafeInteger(Math.round(Number(num)))) { |
| | | showToast("输入数字超出数值安全范围") |
| | | } |
| | | } |
| | | } |
| | | this.stationEdit.x = event.detail.value |
| | | this.stationEdit.x = Number(event.detail.value) |
| | | |
| | | }, |
| | | onInputY(event) { |
| | | const strictRegex = /^[-+]?(\d+\.?\d*|\.\d+)$/; |
| | | let num = event.detail.value |
| | | if (!strictRegex.test(num)) { |
| | | showToast("输入内容只能包含数字、正负号和小数点") |
| | | } else { |
| | | if (Math.round(Number(num)) === Number(num)) { |
| | | if (!Number.isSafeInteger(Number(num))) { |
| | | showToast("输入数字超出数值安全范围") |
| | | if (!this.validateNumber(num)) { |
| | | showToast(this.translate("input_content_only_numbers_and_signs_and_decimal")) |
| | | return |
| | | } |
| | | } else { |
| | | if (!Number.isSafeInteger(Math.round(Number(num)))) { |
| | | showToast("输入数字超出数值安全范围") |
| | | } |
| | | } |
| | | |
| | | } |
| | | this.stationEdit.y = event.detail.value |
| | | this.stationEdit.y = Number(event.detail.value) |
| | | |
| | | }, |
| | | getStantardAngle(angle) { |
| | |
| | | this.angleSvg = `/static/images/angle${angle}.svg` |
| | | this.stationEdit.angle = angle * 3.14 / 180 |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | |
| | | |
| | | translate(t) { |
| | | if (typeof this.$t == "function") return this.$t(`page.${t}`) |
| | | else return t; |
| | | }, |
| | | } |
| | | } |
| | | </script> |