From ace122e940219824347df1ed291d84ce8ecc9a4a Mon Sep 17 00:00:00 2001 From: xudan Date: Thu, 7 Aug 2025 16:45:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=BA=93=E4=BD=8D?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=A1=AE=E8=AE=A4=E5=AF=B9=E8=AF=9D=E6=A1=86?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=BC=BA=E7=94=A8=E6=88=B7=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=80=A7=E5=B9=B6=E4=BC=98=E5=8C=96=E5=BA=93?= =?UTF-8?q?=E4=BD=8D=E7=AE=A1=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/card/point-edit-card.vue | 43 +++++++++++++++++++++---- src/services/editor.service.ts | 2 +- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/components/card/point-edit-card.vue b/src/components/card/point-edit-card.vue index 9ba12df..9b05c0b 100644 --- a/src/components/card/point-edit-card.vue +++ b/src/components/card/point-edit-card.vue @@ -14,6 +14,7 @@ import type { PointBindModalRef } from '@common/modal/point-bind-modal.vue'; import type { RobotBindModalRef } from '@common/modal/robot-bind-modal.vue'; import type { EditorService } from '@core/editor.service'; import sTheme from '@core/theme.service'; +import { Modal } from 'ant-design-vue'; import { isNil } from 'lodash-es'; import { ref, shallowRef } from 'vue'; import { computed, inject, type InjectionKey, type ShallowRef } from 'vue'; @@ -108,13 +109,43 @@ function onRemoveLocation(i: number) { const p = point.value!; if (p.associatedStorageLocations) { const removedLocationName = p.associatedStorageLocations[i]; - p.associatedStorageLocations.splice(i, 1); - editor.value.updatePen(props.id!, { point: { ...p } }, false); - - // 同步更新地图文件中的binLocationList(删除库位) const pointName = pen.value?.label || pen.value?.id || ''; - if (pointName && removedLocationName) { - editor.value.removeBinLocation(pointName, removedLocationName); + + // 检查该库位是否存在BinLocation配置 + const hasBinLocation = + pointName && removedLocationName && editor.value.checkBinLocationExists(pointName, removedLocationName); + + if (hasBinLocation) { + // 如果存在BinLocation配置,显示确认对话框 + Modal.confirm({ + title: '确认删除', + content: '该库位存在Bintask库位配置,是否删除?', + okText: '确认', + cancelText: '取消', + onOk: () => { + // 用户确认后执行删除操作 + if (p.associatedStorageLocations) { + p.associatedStorageLocations.splice(i, 1); + editor.value.updatePen(props.id!, { point: { ...p } }, false); + + // 同步更新地图文件中的binLocationList(删除库位) + if (pointName && removedLocationName) { + editor.value.removeBinLocation(pointName, removedLocationName); + } + } + }, + }); + } else { + // 如果不存在BinLocation配置,直接删除 + if (p.associatedStorageLocations) { + p.associatedStorageLocations.splice(i, 1); + editor.value.updatePen(props.id!, { point: { ...p } }, false); + + // 同步更新地图文件中的binLocationList(删除库位) + if (pointName && removedLocationName) { + editor.value.removeBinLocation(pointName, removedLocationName); + } + } } } } diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index d8b117b..d2eccea 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -129,7 +129,7 @@ export class EditorService extends Meta2d { * @param locationName 库位名称 * @returns 如果库位项存在则返回true,否则返回false */ - private checkBinLocationExists(pointName: string, locationName: string): boolean { + public checkBinLocationExists(pointName: string, locationName: string): boolean { const binLocationGroups = this.getBinLocationGroups(); return binLocationGroups.some(