Quellcode durchsuchen

当物资柜的点位移动到左右列表外的时候在外面移动时保证json不新增再次移动回去时保证json要新增

pm vor 9 Monaten
Ursprung
Commit
cfddc9500b
1 geänderte Dateien mit 15 neuen und 3 gelöschten Zeilen
  1. 15 3
      src/views/mes/hw/lotoStation/MapData.vue

+ 15 - 3
src/views/mes/hw/lotoStation/MapData.vue

@@ -959,14 +959,26 @@ export default {
               // 如果点不在 positions 中,可能是从右侧或左侧列表移动回来
               const rightIndex = this.rightPoints.findIndex(item => item.pointName === labelText)
               const leftIndex = this.leftPoints.findIndex(item => item.pointName === labelText)
-
-              if (rightIndex !== -1) {
+              if (rightIndex !== -1 && isInLeftBox) {
+                // 从右侧拖拽到左侧
+                const movedPoint = this.rightPoints.splice(rightIndex, 1)[0];
+                if (!this.leftPoints.find(point => point.pointName === movedPoint.pointName)) {
+                  this.leftPoints.push(movedPoint);
+                }
+              } else if (leftIndex !== -1 && isInRightBox) {
+                // 从左侧拖拽到右侧
+                const movedPoint = this.leftPoints.splice(leftIndex, 1)[0];
+                if (!this.rightPoints.find(point => point.pointName === movedPoint.pointName)) {
+                  this.rightPoints.push(movedPoint);
+                }
+              }
+              if (rightIndex !== -1&&isInCabinet) {
                 // 从右侧列表移回物资柜
                 const movedPoint = this.rightPoints.splice(rightIndex, 1)[0]
                 positions.push(movedPoint)
                 // 更新 this.value
                 this.value = JSON.stringify(positions, null, 4)
-              } else if (leftIndex !== -1) {
+              } else if (leftIndex !== -1&&isInCabinet) {
                 // 从左侧列表移回物资柜
                 const movedPoint = this.leftPoints.splice(leftIndex, 1)[0]
                 positions.push(movedPoint)