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(