diff --git a/src/components/draw-app/properties/AxleCountingProperty.vue b/src/components/draw-app/properties/AxleCountingProperty.vue index a7420b2..e826d6c 100644 --- a/src/components/draw-app/properties/AxleCountingProperty.vue +++ b/src/components/draw-app/properties/AxleCountingProperty.vue @@ -243,13 +243,15 @@ function oneClickAxleCounting() { axleCounting.id = GraphicIdGenerator.next(); const offsetX = i == 0 ? -40 : 40; axleCounting.position.set(select.x + offsetX, select.y + 30); - const refIndex = i == 0 ? 1 : 0; - const ref = select.datas.axleCountingRef[refIndex]; - const refSection = select.queryStore.queryById(ref.id); - axleCounting.datas.axleCountingRef = [ - select.datas.axleCountingRef[refIndex], - ]; - axleCounting.datas.code = `${refSection.code}-${ref.devicePort}`; + const ref = select.datas.axleCountingRef; + for (let j = 0; j < 2; j++) { + if (ref[j].devicePort == i) { + const refSection = select.queryStore.queryById(ref[j].id) as Section; + axleCounting.datas.axleCountingRef = [select.datas.axleCountingRef[j]]; + axleCounting.datas.code = `${refSection.datas.code}-${ref[j].devicePort}`; + break; + } + } const app = drawStore.getDrawApp(); app.addGraphicAndRecord(axleCounting); axleCounting.loadRelations();