feat: 添加库位删除确认对话框,增强用户操作安全性并优化库位管理逻辑
This commit is contained in:
parent
153cbfa467
commit
ace122e940
@ -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,15 +109,45 @@ function onRemoveLocation(i: number) {
|
||||
const p = point.value!;
|
||||
if (p.associatedStorageLocations) {
|
||||
const removedLocationName = p.associatedStorageLocations[i];
|
||||
const pointName = pen.value?.label || pen.value?.id || '';
|
||||
|
||||
// 检查该库位是否存在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(删除库位)
|
||||
const pointName = pen.value?.label || pen.value?.id || '';
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function onChangeLocation(i: number, v: string) {
|
||||
const p = point.value!;
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user