wuyouming666
2025-04-07 2761fdf62f9f6c0dd931812589643adbe40efb83
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
@@ -138,10 +138,10 @@
        return;
      }
      const parsedData = JSON.parse(response.data);
      if (parsedData.display && parsedData.display.frameNumber) {
      if (parsedData.display && parsedData.frameNumber) {
        showJiaHao.value = parsedData.display.frameNumber;
      }
      if (parsedData.display && parsedData.display.orderNumber) {
      if (parsedData.display && parsedData.orderNumber) {
        showProcessId.value = parsedData.display.orderNumber;
      }
      if (parsedData.display) {
@@ -389,6 +389,22 @@
    document.body.removeChild(contextMenu);
  });
  const mirrorXItem = document.createElement('div');
  mirrorXItem.textContent = 'X镜像';
  mirrorXItem.style.cursor = 'pointer';
  mirrorXItem.addEventListener('click', () => {
    mirrorLayoutX(layoutIndex);
    document.body.removeChild(contextMenu);
  });
  const mirrorYItem = document.createElement('div');
  mirrorYItem.textContent = 'Y镜像';
  mirrorYItem.style.cursor = 'pointer';
  mirrorYItem.addEventListener('click', () => {
    mirrorLayoutY(layoutIndex);
    document.body.removeChild(contextMenu);
  });
  contextMenu.appendChild(rotateItem);
  contextMenu.appendChild(moveUpAndRotateItem);
  contextMenu.appendChild(moveDownAndRotateItem);
@@ -400,6 +416,8 @@
  contextMenu.appendChild(moveRightItem);
  contextMenu.appendChild(deleteItem);
  contextMenu.appendChild(addItem);
  contextMenu.appendChild(mirrorXItem);
  contextMenu.appendChild(mirrorYItem);
  document.body.appendChild(contextMenu);
};
@@ -426,7 +444,25 @@
    document.body.removeChild(contextMenu);
  });
  const mirrorXItem = document.createElement('div');
  mirrorXItem.textContent = 'X镜像';
  mirrorXItem.style.cursor = 'pointer';
  mirrorXItem.addEventListener('click', () => {
    mirrorLayoutX(layoutIndex);
    document.body.removeChild(contextMenu);
  });
  const mirrorYItem = document.createElement('div');
  mirrorYItem.textContent = 'Y镜像';
  mirrorYItem.style.cursor = 'pointer';
  mirrorYItem.addEventListener('click', () => {
    mirrorLayoutY(layoutIndex);
    document.body.removeChild(contextMenu);
  });
  contextMenu.appendChild(addItem);
  contextMenu.appendChild(mirrorXItem);
  contextMenu.appendChild(mirrorYItem);
  document.body.appendChild(contextMenu);
};
@@ -502,7 +538,7 @@
    rect.x = Math.round(rect.x);
    rect.y = Math.round(rect.y);
    //adjustAlignmentPosition(layoutIndex, rectIndex);
    adjustAlignmentPosition(layoutIndex, rectIndex);
    adjustGrayRectangles(layoutIndex);
  }
@@ -545,7 +581,6 @@
  // 调整后重新计算灰色余料
  adjustGrayRectangles(layoutIndex);
};
const mergeAdjacentGrayRects = (rects) => {
  const grayRects = rects.filter(r => r.isRemain);
@@ -643,7 +678,8 @@
  otherRects.forEach(otherRect => {
    if (checkOverlap(rect, otherRect)) {
      isValidRotation = false    }
      isValidRotation = false;
    }
  });
  if (rect.x + rect.w > layout.width || rect.y + rect.h > layout.height) {
@@ -940,11 +976,48 @@
  }
};
const mirrorLayoutX = (layoutIndex) => {
  const layout = layouts.value[layoutIndex];
  const width = layout.width;
  const rects = [...layout.rects]; // 创建副本避免直接修改
  rects.forEach(rect => {
    // 计算X镜像后的坐标
    const newX = width - rect.x - rect.w;
    const newY = rect.y;
    // 更新矩形位置
    rect.x = newX;
    rect.y = newY;
  });
  // 更新布局
  layout.rects = rects;
  adjustGrayRectangles(layoutIndex);
};
const mirrorLayoutY = (layoutIndex) => {
  const layout = layouts.value[layoutIndex];
  const height = layout.height;
  const rects = [...layout.rects]; // 创建副本避免直接修改
  rects.forEach(rect => {
    // 计算Y镜像后的坐标
    const newX = rect.x;
    const newY = height - rect.y - rect.h;
    // 更新矩形位置
    rect.y = newY;
  });
  // 更新布局
  layout.rects = rects;
  adjustGrayRectangles(layoutIndex);
};
onMounted(() => {
  fetchSettings(username);
  setTimeout(updateLayout, 500);
 updateLayout();
  selectedLayoutIndex.value = 0;
@@ -960,8 +1033,6 @@
  document.addEventListener('keyup', handleKeyUp);
});
onUnmounted(() => {
  rectsElements.value = {};
  if (clickEventListener) {
@@ -971,9 +1042,7 @@
  document.removeEventListener('keydown', handleKeyDown);
  document.removeEventListener('keyup', handleKeyUp);
});
</script>
<style scoped>
.layout-wrapper {
@@ -1001,25 +1070,28 @@
}
.rect-content {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 5px;
  min-width: 60px;
  min-height: 20px;
  white-space: normal;
  overflow-wrap: break-word;
}
.size {
  grid-row: 1;
  grid-column: 1;
  color: #444;
  font-size: 12px;
  color: #444;
  white-space: normal;
  word-wrap: break-word;
}
.jia-hao, .liuchengka {
  grid-row: 2;
  grid-column: 1;
  margin: auto;
  font-size: 14px;
  font-weight: bold;
  white-space: normal;
  word-wrap: break-word;
}
.sidebar-item {