From cc144144ddd5fbfc7b7dce87444962cf08b95e28 Mon Sep 17 00:00:00 2001
From: 于杰 <1210123631@qq.com>
Date: 星期二, 02 十二月 2025 16:38:19 +0800
Subject: [PATCH] 关闭鼠标拖拽小片功能,修复移动数值错误bug
---
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue | 244 ++++++++++++++++++++++++------------------------
1 files changed, 120 insertions(+), 124 deletions(-)
diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
index 4d4b39b..29fe2c2 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
+++ b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
@@ -53,10 +53,6 @@
class="layout-glassDetail"
:style="rectStyle(glassDetail, layoutIndex)"
@contextmenu.prevent="handleRectRightClick(layoutIndex, rectIndex)"
- @mousedown="handleRectDragStart(layoutIndex, rectIndex)"
- @mousemove="handleRectDragging"
- @mouseup="handleRectDragEnd"
- @mouseleave="handleRectDragEnd"
@click="handleRectClick(layoutIndex, rectIndex)"
>
<div class="glassDetail-content">
@@ -108,9 +104,9 @@
const rectClass = ref('layout-glassDetail');
const selectedLayoutIndex = ref(0);
const currentRect = ref(null);
-const dragging = ref(false);
-const dragStartPos = ref({ x: 0, y: 0 });
-const dragRect = ref(null);
+// const dragging = ref(false);
+// const dragStartPos = ref({ x: 0, y: 0 });
+// const dragRect = ref(null);
const showJiaHao = ref(false);
const showProcessId = ref(false);
const themeColor = ref(null);
@@ -344,9 +340,9 @@
//鐐瑰嚮灏忕墖
const handleRectClick = (layoutIndex, rectIndex) => {
- if (dragging.value) {
- return;
- }
+ // if (dragging.value) {
+ // return;
+ // }
focusIndex.value = { layoutIndex, rectIndex };
emit('rectClicked', layoutIndex, rectIndex);
@@ -535,122 +531,122 @@
};
//灏忕墖榧犳爣鎸変笅浜嬩欢
-const handleRectDragStart = (layoutIndex, rectIndex) => {
- const layout = layouts.value[layoutIndex];
- const glassDetail = layout.glassDetails[rectIndex];
- if (glassDetail.isRemain) return;
+// const handleRectDragStart = (layoutIndex, rectIndex) => {
+// const layout = layouts.value[layoutIndex];
+// const glassDetail = layout.glassDetails[rectIndex];
+// if (glassDetail.isRemain) return;
+//
+// dragRect.value = { layoutIndex, rectIndex };
+// dragStartPos.value = {
+// x: event.clientX,
+// y: event.clientY
+// };
+// };
- dragRect.value = { layoutIndex, rectIndex };
- dragStartPos.value = {
- x: event.clientX,
- y: event.clientY
- };
-};
+// //灏忕墖榧犳爣绉诲姩浜嬩欢
+// const handleRectDragging = (event) => {
+// if (!dragRect.value) return;
+//
+// // 濡傛灉杩樻病纭鏄嫋鎷斤紝鍒欏厛鍒ゆ柇鏄惁杈惧埌鎷栨嫿闃堝��(渚嬪5鍍忕礌)
+// if (!dragging.value) {
+// const deltaX = event.clientX - dragStartPos.value.x;
+// const deltaY = event.clientY - dragStartPos.value.y;
+// const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+//
+// // 濡傛灉绉诲姩璺濈灏忎簬闃堝�硷紝鍒欒涓烘槸鐐瑰嚮鑰岄潪鎷栨嫿
+// if (distance < 5) {
+// return;
+// }
+//
+// // 杈惧埌闃堝�硷紝纭鏄嫋鎷芥搷浣�
+// dragging.value = true;
+// }
+//
+// const layoutIndex = dragRect.value.layoutIndex;
+// const rectIndex = dragRect.value.rectIndex;
+// const layout = layouts.value[layoutIndex];
+// const glassDetail = layout.glassDetails[rectIndex];
+//
+// // 淇濆瓨鍘熷鍧愭爣鐢ㄤ簬璁$畻鍋忕Щ閲�
+// const originalX = glassDetail.x;
+// const originalY = glassDetail.y;
+//
+// const scale = Math.min(
+// (props.gw - 100) / layout.width,
+// (props.gh - 100) / layout.height
+// );
+//
+// const deltaX = event.clientX - dragStartPos.value.x;
+// const deltaY = event.clientY - dragStartPos.value.y;
+//
+// const newRect = { ...glassDetail };
+// newRect.x += deltaX / scale;
+// newRect.y += deltaY / scale;
+//
+// const otherRects = layout.glassDetails.filter(r => !r.isRemain && r !== glassDetail);
+// let isValidMove = true;
+//
+// otherRects.forEach(otherRect => {
+// if (checkOverlap(newRect, otherRect)) {
+// isValidMove = false;
+// }
+// });
+//
+// if (newRect.x < 0 || newRect.y < 0 ||
+// newRect.x + newRect.width > layout.width ||
+// newRect.y + newRect.height > layout.height) {
+// isValidMove = false;
+// }
+//
+// if (isValidMove) {
+// glassDetail.x = newRect.x;
+// glassDetail.y = newRect.y;
+//
+// // 鏇存柊glassPoint鍧愭爣
+// if (glassDetail.glassPoint && Array.isArray(glassDetail.glassPoint)) {
+// const offsetX = glassDetail.x - originalX;
+// const offsetY = glassDetail.y - originalY;
+//
+// glassDetail.glassPoint.forEach(point => {
+// point.X += offsetX;
+// point.Y += offsetY;
+// // 娣诲姞绮惧害鎺у埗
+// point.X = parseFloat(point.X.toFixed(2));
+// point.Y = parseFloat(point.Y.toFixed(2));
+// });
+// }
+//
+// dragStartPos.value = {
+// x: event.clientX,
+// y: event.clientY
+// };
+// adjustGrayRectangles(layoutIndex);
+// }
+// };
-//灏忕墖榧犳爣绉诲姩浜嬩欢
-const handleRectDragging = (event) => {
- if (!dragRect.value) return;
-
- // 濡傛灉杩樻病纭鏄嫋鎷斤紝鍒欏厛鍒ゆ柇鏄惁杈惧埌鎷栨嫿闃堝��(渚嬪5鍍忕礌)
- if (!dragging.value) {
- const deltaX = event.clientX - dragStartPos.value.x;
- const deltaY = event.clientY - dragStartPos.value.y;
- const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
-
- // 濡傛灉绉诲姩璺濈灏忎簬闃堝�硷紝鍒欒涓烘槸鐐瑰嚮鑰岄潪鎷栨嫿
- if (distance < 5) {
- return;
- }
-
- // 杈惧埌闃堝�硷紝纭鏄嫋鎷芥搷浣�
- dragging.value = true;
- }
-
- const layoutIndex = dragRect.value.layoutIndex;
- const rectIndex = dragRect.value.rectIndex;
- const layout = layouts.value[layoutIndex];
- const glassDetail = layout.glassDetails[rectIndex];
-
- // 淇濆瓨鍘熷鍧愭爣鐢ㄤ簬璁$畻鍋忕Щ閲�
- const originalX = glassDetail.x;
- const originalY = glassDetail.y;
-
- const scale = Math.min(
- (props.gw - 100) / layout.width,
- (props.gh - 100) / layout.height
- );
-
- const deltaX = event.clientX - dragStartPos.value.x;
- const deltaY = event.clientY - dragStartPos.value.y;
-
- const newRect = { ...glassDetail };
- newRect.x += deltaX / scale;
- newRect.y += deltaY / scale;
-
- const otherRects = layout.glassDetails.filter(r => !r.isRemain && r !== glassDetail);
- let isValidMove = true;
-
- otherRects.forEach(otherRect => {
- if (checkOverlap(newRect, otherRect)) {
- isValidMove = false;
- }
- });
-
- if (newRect.x < 0 || newRect.y < 0 ||
- newRect.x + newRect.width > layout.width ||
- newRect.y + newRect.height > layout.height) {
- isValidMove = false;
- }
-
- if (isValidMove) {
- glassDetail.x = newRect.x;
- glassDetail.y = newRect.y;
-
- // 鏇存柊glassPoint鍧愭爣
- if (glassDetail.glassPoint && Array.isArray(glassDetail.glassPoint)) {
- const offsetX = glassDetail.x - originalX;
- const offsetY = glassDetail.y - originalY;
-
- glassDetail.glassPoint.forEach(point => {
- point.X += offsetX;
- point.Y += offsetY;
- // 娣诲姞绮惧害鎺у埗
- point.X = parseFloat(point.X.toFixed(2));
- point.Y = parseFloat(point.Y.toFixed(2));
- });
- }
-
- dragStartPos.value = {
- x: event.clientX,
- y: event.clientY
- };
- adjustGrayRectangles(layoutIndex);
- }
-};
-
-//灏忕墖榧犳爣鏉惧紑浜嬩欢
-const handleRectDragEnd = () => {
- dragging.value = false;
- dragRect.value = null;
- dragStartPos.value = { x: 0, y: 0 };
- if (dragRect.value) {
- const layoutIndex = dragRect.value.layoutIndex;
- const rectIndex = dragRect.value.rectIndex;
- const glassDetail = layouts.value[layoutIndex].glassDetails[rectIndex];
- const layout = layouts.value[layoutIndex];
- const scale = Math.min(
- (props.gw - 100) / layout.width,
- (props.gh - 100) / layout.height
- );
-
- glassDetail.x = parseFloat(glassDetail.x.toFixed(2));
- glassDetail.y = parseFloat(glassDetail.y.toFixed(2));
- adjustAlignmentPosition(layoutIndex, rectIndex);
- }
-
- dragging.value = false;
- dragRect.value = null;
-};
+// //灏忕墖榧犳爣鏉惧紑浜嬩欢
+// const handleRectDragEnd = () => {
+// dragging.value = false;
+// dragRect.value = null;
+// dragStartPos.value = { x: 0, y: 0 };
+// if (dragRect.value) {
+// const layoutIndex = dragRect.value.layoutIndex;
+// const rectIndex = dragRect.value.rectIndex;
+// const glassDetail = layouts.value[layoutIndex].glassDetails[rectIndex];
+// const layout = layouts.value[layoutIndex];
+// const scale = Math.min(
+// (props.gw - 100) / layout.width,
+// (props.gh - 100) / layout.height
+// );
+//
+// glassDetail.x = parseFloat(glassDetail.x.toFixed(2));
+// glassDetail.y = parseFloat(glassDetail.y.toFixed(2));
+// adjustAlignmentPosition(layoutIndex, rectIndex);
+// }
+//
+// dragging.value = false;
+// dragRect.value = null;
+// };
const adjustAlignmentPosition = (layoutIndex, rectIndex) => {
const layout = layouts.value[layoutIndex];
--
Gitblit v1.8.0