From b8a452ae67c99a4279b9450d1aa7158a29bc45c9 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期二, 25 三月 2025 08:30:02 +0800
Subject: [PATCH] 版图调整、打印

---
 north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue |  169 ++++++++++++++++++++++++++-----------------------------
 1 files changed, 80 insertions(+), 89 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 0f40d96..ea5170a 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,7 +53,8 @@
           >
             <div class="rect-content">
               <div class="size">{{ rect.w }}脳{{ rect.h }}</div>
-              <div class="jia-hao">{{ rect.JiaHao }}</div>
+              <div v-if="showJiaHao" class="jia-hao">{{ rect.JiaHao }}</div>
+              <div v-if="showProcessId" class="liuchengka">{{ rect.liuchengka }}</div>
             </div>
           </div>
         </div>
@@ -72,7 +73,13 @@
 import request from "@/utils/request";
 import { useI18n } from "vue-i18n";
 import { ElMessage, ElMessageBox } from "element-plus";
+import useUserInfoStore from "@/stores/userInfo";
+
 const { t } = useI18n();
+const userStore = useUserInfoStore()
+const username = userStore.user.userName
+
+
 const props = defineProps({
   layoutData: { type: Object, required: true },
   gw: { type: Number, default: 1000 },
@@ -93,7 +100,9 @@
 const dragging = ref(false);
 const dragStartPos = ref({ x: 0, y: 0 });
 const dragRect = ref(null);
-
+const showJiaHao = ref(false); // 鏂板锛氭帶鍒秊ia-hao鐨勬樉绀虹姸鎬�
+const showProcessId= ref(false);
+const themeColor=ref(null)
 // 鎻愪氦甯冨眬鏁版嵁鍒板悗绔�
 const submitLayouts = async () => {
   layouts.value.forEach(layout => {
@@ -119,6 +128,44 @@
     }
   });
 };
+
+
+//鑾峰彇浼樺寲璁剧疆
+const fetchSettings = async (username) => {
+  try {
+    const response = await request.post(`/glassOptimize/selectOptimizeParms/${username}`);
+    if (response.code == 200) {
+      if (!response.data) {
+        console.error('鍝嶅簲鏁版嵁涓虹┖');
+        return;
+      }
+      const parsedData = JSON.parse(response.data);
+      console.log(parsedData.display.frameNumber)
+      if (parsedData.display && parsedData.display.frameNumber) {
+        showJiaHao.value = parsedData.display.frameNumber;
+
+      }
+      if (parsedData.display && parsedData.display.orderNumber) {
+        showProcessId.value = parsedData.display.orderNumber;
+      
+      }
+      if (parsedData.display ) {
+        themeColor.value = parsedData.display.themeColor;
+      
+      }
+      
+      
+      
+      console.log( parsedData);
+    } else {
+      console.error('璇锋眰澶辫触锛岀姸鎬佺爜:', response.code);
+    }
+  } catch (error) {
+    console.error('璇锋眰鍙戠敓閿欒:', error);
+  }
+};
+
+
 
 const showAddDialog = (layoutIndex, rectIndex) => {
   ElMessageBox.prompt('璇疯緭鍏ユ垚鍝佺殑瀹藉害鍜岄珮搴�', '娣诲姞鎴愬搧', {
@@ -146,8 +193,8 @@
       y: 0,
       w: values[0],
       h: values[1],
-      isRemain: false,
-      JiaHao: `鏂版垚鍝乣
+      isRemain: false
+     
     };
     addNewRect(layoutIndex, newRect);
   })
@@ -210,7 +257,7 @@
     top: `${rect.y * scale}px`,
     width: `${rect.w * scale}px`,
     height: `${rect.h * scale}px`,
-    backgroundColor: rect.isRemain ? '#f0f0f0' : '#a0d8ef',
+    backgroundColor: rect.isRemain ? '#f0f0f0' : themeColor.value,
     border: '1px solid #000',
     cursor: 'pointer',
     draggable: !rect.isRemain,
@@ -354,38 +401,6 @@
   contextMenu.style.padding = '5px';
   contextMenu.style.zIndex = 1001;
 
-  const mergeLeftItem = document.createElement('div');
-  mergeLeftItem.textContent = '鍚戝乏鍚堝苟';
-  mergeLeftItem.style.cursor = 'pointer';
-  mergeLeftItem.addEventListener('click', () => {
-    mergeGrayRects(layoutIndex, rectIndex, 'left');
-    document.body.removeChild(contextMenu);
-  });
-
-  const mergeRightItem = document.createElement('div');
-  mergeRightItem.textContent = '鍚戝彸鍚堝苟';
-  mergeRightItem.style.cursor = 'pointer';
-  mergeRightItem.addEventListener('click', () => {
-    mergeGrayRects(layoutIndex, rectIndex, 'right');
-    document.body.removeChild(contextMenu);
-  });
-
-  const mergeUpItem = document.createElement('div');
-  mergeUpItem.textContent = '鍚戜笂鍚堝苟';
-  mergeUpItem.style.cursor = 'pointer';
-  mergeUpItem.addEventListener('click', () => {
-    mergeGrayRects(layoutIndex, rectIndex, 'up');
-    document.body.removeChild(contextMenu);
-  });
-
-  const mergeDownItem = document.createElement('div');
-  mergeDownItem.textContent = '鍚戜笅鍚堝苟';
-  mergeDownItem.style.cursor = 'pointer';
-  mergeDownItem.addEventListener('click', () => {
-    mergeGrayRects(layoutIndex, rectIndex, 'down');
-    document.body.removeChild(contextMenu);
-  });
-
   const addItem = document.createElement('div');
   addItem.textContent = '娣诲姞鎴愬搧';
   addItem.style.cursor = 'pointer';
@@ -394,10 +409,6 @@
     document.body.removeChild(contextMenu);
   });
 
-  contextMenu.appendChild(mergeLeftItem);
-  contextMenu.appendChild(mergeRightItem);
-  contextMenu.appendChild(mergeUpItem);
-  contextMenu.appendChild(mergeDownItem);
   contextMenu.appendChild(addItem);
 
   document.body.appendChild(contextMenu);
@@ -480,7 +491,7 @@
     rect.y = Math.round(rect.y);
 
     // 鍙皟鏁翠綅缃榻愶紝涓嶈皟鏁村ぇ灏�
-    //adjustAlignmentPosition(layoutIndex, rectIndex);
+    adjustAlignmentPosition(layoutIndex, rectIndex);
 
     // 璋冩暣鐏拌壊鐭╁舰
     adjustGrayRectangles(layoutIndex);
@@ -513,49 +524,6 @@
   });
 };
 
-const mergeGrayRects = (layoutIndex, rectIndex, direction) => {
-  const layout = layouts.value[layoutIndex];
-  const rect = layout.rects[rectIndex];
-  const grayRects = layout.rects.filter(r => r.isRemain);
-
-  let targetRect = null;
-
-  switch (direction) {
-    case 'left':
-      targetRect = grayRects.find(r => r.x + r.w === rect.x && r.y === rect.y && r.h === rect.h);
-      break;
-    case 'right':
-      targetRect = grayRects.find(r => r.x === rect.x + rect.w && r.y === rect.y && r.h === rect.h);
-      break;
-    case 'up':
-      targetRect = grayRects.find(r => r.y + r.h === rect.y && r.x === rect.x && r.w === rect.w);
-      break;
-    case 'down':
-      targetRect = grayRects.find(r => r.y === rect.y + rect.h && r.x === rect.x && r.w === rect.w);
-      break;
-  }
-
-  if (targetRect) {
-    const mergedRect = {
-      x: Math.min(rect.x, targetRect.x),
-      y: Math.min(rect.y, targetRect.y),
-      w: Math.max(rect.x + rect.w, targetRect.x + targetRect.w) - Math.min(rect.x, targetRect.x),
-      h: Math.max(rect.y + rect.h, targetRect.y + targetRect.h) - Math.min(rect.y, targetRect.y),
-      isRemain: true
-    };
-
-    const index = layout.rects.indexOf(rect);
-    layout.rects.splice(index, 1);
-    const targetIndex = layout.rects.indexOf(targetRect);
-    layout.rects.splice(targetIndex, 1);
-    layout.rects.push(mergedRect);
-
-    adjustGrayRectangles(layoutIndex);
-  } else {
-    ElMessage.warning('鏃犳硶鍚堝苟锛屾病鏈夌浉閭荤殑鐏拌壊鐭╁舰');
-  }
-};
-
 const mergeAdjacentGrayRects = (rects) => {
   const grayRects = rects.filter(r => r.isRemain);
   let merged = [];
@@ -585,7 +553,7 @@
                current.x === last.x && 
                current.w === last.w) {
       last.h += current.h;
-      last.x = Math.round(last);
+      last.x = Math.round(last.x);
       last.y = Math.round(last.y);
       last.w = Math.round(last.w);
       last.h = Math.round(last.h);
@@ -745,7 +713,7 @@
       rect.x -= actualStep;
       break;
     case 'right':
-      rect.x += actualStep;
+      rect.x +=actualStep;
       break;
   }
 
@@ -861,14 +829,33 @@
   layouts.value = props.layoutData.Layouts;
 };
 
+
+let clickEventListener = null;
 onMounted(() => {
-  setTimeout(updateLayout, 1000);
+  fetchSettings(username);
+  setTimeout(updateLayout, 500);
 
   selectedLayoutIndex.value = 0;
+
+   // 娣诲姞鍏ㄥ眬鐐瑰嚮浜嬩欢鐩戝惉鍣�
+   clickEventListener = (event) => {
+    // 妫�鏌ユ槸鍚﹀瓨鍦ㄥ彸閿彍鍗�
+    const contextMenus = document.querySelectorAll('.context-menu');
+    if (contextMenus.length > 0) {
+      // 绉婚櫎鎵�鏈夊彸閿彍鍗�
+      contextMenus.forEach(menu => menu.remove());
+    }
+  };
+  document.addEventListener('click', clickEventListener);
+
 });
 
 onUnmounted(() => {
   rectsElements.value = {};
+   // 绉婚櫎鍏ㄥ眬鐐瑰嚮浜嬩欢鐩戝惉鍣�
+   if (clickEventListener) {
+    document.removeEventListener('click', clickEventListener);
+  }
 });
 </script>
 
@@ -876,6 +863,10 @@
 .layout-wrapper {
   position: relative;
   margin-top: 50px;
+}
+
+.layout-rect {
+  user-select: none;
 }
 
 .layout-container {
@@ -907,7 +898,7 @@
   font-size: 12px;
 }
 
-.jia-hao {
+.jia-hao .liuchengka {
   grid-row: 2;
   grid-column: 1;
   margin: auto;

--
Gitblit v1.8.0