From 0ce15e11d27bc5098f221af9acb6a16968d468fa Mon Sep 17 00:00:00 2001 From: xudan Date: Wed, 30 Jul 2025 11:46:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=BA=93=E4=BD=8D=E5=90=8D=E7=A7=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E5=AD=98=E5=82=A8=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=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 | 34 ++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/components/card/point-edit-card.vue b/src/components/card/point-edit-card.vue index 1e10c72..d3c868f 100644 --- a/src/components/card/point-edit-card.vue +++ b/src/components/card/point-edit-card.vue @@ -66,10 +66,42 @@ const actions = computed( const coArea1 = computed(() => editor.value.getBoundAreas(props.id, 'point', MapAreaType.库区)); const coArea2 = computed(() => editor.value.getBoundAreas(props.id, 'point', MapAreaType.互斥区)); +// 生成默认库位名称 function onAddLocation() { const p = point.value!; if (!p.associatedStorageLocations) p.associatedStorageLocations = []; - p.associatedStorageLocations.push(''); + + // 获取动作点名称(去掉前缀,如 "AP1" -> "AP1") + const pointName = pen.value?.label || ''; + + // 生成默认库位名称 + const generateDefaultLocationName = (): string => { + const existingLocations = p.associatedStorageLocations || []; + const prefix = `${pointName}_`; + + // 找出已存在的符合格式的库位编号 + const existingNumbers = new Set(); + existingLocations.forEach((location) => { + if (location.startsWith(prefix)) { + const suffix = location.substring(prefix.length); + const num = parseInt(suffix, 10); + if (!isNaN(num) && suffix === num.toString().padStart(2, '0')) { + existingNumbers.add(num); + } + } + }); + + // 找到第一个未使用的编号 + let nextNumber = 1; + while (existingNumbers.has(nextNumber)) { + nextNumber++; + } + + return `${prefix}${nextNumber.toString().padStart(2, '0')}`; + }; + + const defaultName = generateDefaultLocationName(); + p.associatedStorageLocations.push(defaultName); editor.value.updatePen(props.id!, { point: { ...p } }, false); } function onRemoveLocation(i: number) {