From eba3314826d53ff0f7e5679d185baaff84e50354 Mon Sep 17 00:00:00 2001
From: guoyujie <guoyujie@ng.com>
Date: 星期四, 04 十二月 2025 10:07:56 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override
---
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue | 265 ++++++++++++++++++++++++++++++----------------------
1 files changed, 153 insertions(+), 112 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 8369231..d07842f 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);
@@ -257,6 +253,12 @@
return bestFit;
};
+const isSelected = (layoutIndex, rectIndex) => {
+ return focusIndex.value &&
+ focusIndex.value.layoutIndex === layoutIndex &&
+ focusIndex.value.rectIndex === rectIndex;
+};
+
//鐗堝浘鍐呭鏍峰紡鍔犺浇
const layoutContainerStyle = (layoutIndex) => {
const layout = layouts.value[layoutIndex];
@@ -308,9 +310,10 @@
//鐗堝浘鍐呭灏忕墖鏍峰紡鍔犺浇
const rectStyle = (glassDetail, layoutIndex) => {
const layout = layouts.value[layoutIndex];
- const scale = Math.min(0.25
- );
- return {
+ const scale = Math.min(0.25);
+ const isSelectedRect = isSelected(layoutIndex, layout.glassDetails.indexOf(glassDetail));
+
+ let style = {
position: 'absolute',
left: `${glassDetail.x * scale}px`,
top: `${glassDetail.y * scale}px`,
@@ -322,13 +325,21 @@
draggable: !glassDetail.isRemain,
zIndex: glassDetail.isRemain ? 1 : 2
};
+
+ // 濡傛灉琚�変腑锛屽垯娣诲姞鍐呬晶绾㈡
+ if (isSelectedRect) {
+ style.boxShadow = 'inset 0 0 0 2px red';
+ }
+
+ return style;
};
const rectStyle1 = (glassDetail, layoutIndex) => {
const layout = layouts.value[layoutIndex];
- const scale = Math.min(0.25
- );
- return {
+ const scale = Math.min(0.25);
+ const isSelectedRect = isSelected(layoutIndex, layout.glassDetails.indexOf(glassDetail));
+
+ let style = {
position: 'absolute',
left: `${glassDetail.x * scale}px`,
top: `${glassDetail.y * scale}px`,
@@ -340,10 +351,21 @@
draggable: !glassDetail.isRemain,
zIndex: glassDetail.isRemain ? 1 : 2
};
+
+ // 濡傛灉琚�変腑锛屽垯娣诲姞鍐呬晶绾㈡
+ if (isSelectedRect) {
+ style.boxShadow = 'inset 0 0 0 2px red';
+ }
+
+ return style;
};
//鐐瑰嚮灏忕墖
const handleRectClick = (layoutIndex, rectIndex) => {
+ // if (dragging.value) {
+ // return;
+ // }
+
focusIndex.value = { layoutIndex, rectIndex };
emit('rectClicked', layoutIndex, rectIndex);
};
@@ -352,12 +374,13 @@
const handleRectRightClick = (layoutIndex, rectIndex) => {
const glassDetail = layouts.value[layoutIndex].glassDetails[rectIndex];
if (glassDetail.isRemain) return;
+ document.querySelectorAll('.context-menu').forEach(el => el.remove());
const contextMenu = document.createElement('div');
contextMenu.className = 'context-menu';
contextMenu.style.position = 'absolute';
contextMenu.style.left = `${event.clientX}px`;
- contextMenu.style.bottom = `${event.clientY}px`;
+ contextMenu.style.top = `${event.clientY}px`;
contextMenu.style.backgroundColor = '#fff';
contextMenu.style.border = '1px solid #ccc';
contextMenu.style.padding = '5px';
@@ -488,12 +511,13 @@
const handleGrayRectRightClick = (layoutIndex, rectIndex,glassDetails) => {
//const glassDetail = glassDetails[rectIndex];
if (!glassDetails.isRemain) return;
+ document.querySelectorAll('.context-menu').forEach(el => el.remove());
const contextMenu = document.createElement('div');
contextMenu.className = 'context-menu';
contextMenu.style.position = 'absolute';
contextMenu.style.left = `${event.clientX}px`;
- contextMenu.style.bottom = `${event.clientY}px`;
+ contextMenu.style.top = `${event.clientY}px`;
contextMenu.style.backgroundColor = '#fff';
contextMenu.style.border = '1px solid #ccc';
contextMenu.style.padding = '5px';
@@ -531,105 +555,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
+// };
+// };
- dragging.value = true;
- 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 (!dragging.value || !dragRect.value) return;
-
- 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 = () => {
- 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