feat: 添加库位删除确认对话框,增强用户操作安全性并优化库位管理逻辑

This commit is contained in:
xudan 2025-08-07 16:45:54 +08:00
parent 153cbfa467
commit ace122e940
2 changed files with 38 additions and 7 deletions

View File

@ -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 { RobotBindModalRef } from '@common/modal/robot-bind-modal.vue';
import type { EditorService } from '@core/editor.service'; import type { EditorService } from '@core/editor.service';
import sTheme from '@core/theme.service'; import sTheme from '@core/theme.service';
import { Modal } from 'ant-design-vue';
import { isNil } from 'lodash-es'; import { isNil } from 'lodash-es';
import { ref, shallowRef } from 'vue'; import { ref, shallowRef } from 'vue';
import { computed, inject, type InjectionKey, type ShallowRef } from 'vue'; import { computed, inject, type InjectionKey, type ShallowRef } from 'vue';
@ -108,13 +109,43 @@ function onRemoveLocation(i: number) {
const p = point.value!; const p = point.value!;
if (p.associatedStorageLocations) { if (p.associatedStorageLocations) {
const removedLocationName = p.associatedStorageLocations[i]; 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 || ''; 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);
}
}
} }
} }
} }

View File

@ -129,7 +129,7 @@ export class EditorService extends Meta2d {
* @param locationName * @param locationName
* @returns truefalse * @returns truefalse
*/ */
private checkBinLocationExists(pointName: string, locationName: string): boolean { public checkBinLocationExists(pointName: string, locationName: string): boolean {
const binLocationGroups = this.getBinLocationGroups(); const binLocationGroups = this.getBinLocationGroups();
return binLocationGroups.some( return binLocationGroups.some(