guoyujie
2025-08-01 cd084621774f86c415e42baf22804e45d3481949
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
@@ -80,7 +80,9 @@
<script setup>
import { ref, reactive, onMounted, onUnmounted } from 'vue';
import { useRouter } from 'vue-router'; // 添加这行
import request from "@/utils/request";
const router = useRouter(); // 添加这行
import { useI18n } from "vue-i18n";
import { ElMessage, ElMessageBox } from "element-plus";
import useUserInfoStore from "@/stores/userInfo";
@@ -126,7 +128,18 @@
  });
  const savedProjectNo = localStorage.getItem('projectNo');
  const processId = savedProjectNo;
  layoutsHead.value.Layouts=layouts.value
  // 构造与原始数据结构一致的对象
  const saveData = {
    projectNo: processId,
    layouts: layouts.value,
    // 复制原始数据中的其他必要字段
    ...layoutsHead.value
  };
  // 确保 Layouts 字段是序列化的字符串
  const requestData = {
    Layouts: JSON.stringify(saveData)
  };
  request.post(`/glassOptimize/updateOptimizeResult/${processId}`, layoutsHead.value, {
    headers: {
      'Content-Type': 'application/json'
@@ -134,6 +147,8 @@
  }).then((res) => {
    if (res.code == 200 && res.data === true) {
      ElMessage.success(t('basicData.msg.saveSuccess'));
      // // 保存成功后跳转到数控界面
      // router.push({ path: '/main/glassOptimize/OptimizeControl' });
    } else {
      ElMessage.warning(res.msg);
    }
@@ -251,7 +266,7 @@
  return {
    position: 'absolute',
    left: `${layout.leftTrim * scale}px`,
    top: `${layout.upTrim * scale}px`,
    bottom: `${layout.upTrim * scale}px`,
    width: `${layout.width * scale}px`,
    height: `${layout.height * scale}px`,
    overflow: 'visible',
@@ -299,7 +314,7 @@
  return {
    position: 'absolute',
    left: `${glassDetail.x * scale}px`,
    bottom: `${glassDetail.y * scale}px`,
    top: `${glassDetail.y * scale}px`,
    width: `${glassDetail.width * scale}px`,
    height: `${glassDetail.height * scale}px`,
    backgroundColor: glassDetail.isRemain ? '#f0f0f0' : themeColor.value,
@@ -361,7 +376,7 @@
  moveUpAndRotateItem.textContent = '向上移动并旋转';
  moveUpAndRotateItem.style.cursor = 'pointer';
  moveUpAndRotateItem.addEventListener('click', () => {
    moveRectAndRotate(layoutIndex, rectIndex, 'up');
    moveRectAndRotate(layoutIndex, rectIndex, 'down');
    document.body.removeChild(contextMenu);
  });
@@ -369,7 +384,7 @@
  moveDownAndRotateItem.textContent = '向下移动并旋转';
  moveDownAndRotateItem.style.cursor = 'pointer';
  moveDownAndRotateItem.addEventListener('click', () => {
    moveRectAndRotate(layoutIndex, rectIndex, 'down');
    moveRectAndRotate(layoutIndex, rectIndex, 'up');
    document.body.removeChild(contextMenu);
  });
@@ -393,7 +408,7 @@
  moveUpItem.textContent = '向上移动';
  moveUpItem.style.cursor = 'pointer';
  moveUpItem.addEventListener('click', () => {
    moveRect(layoutIndex, rectIndex, 'up');
    moveRect(layoutIndex, rectIndex, 'down');
    document.body.removeChild(contextMenu);
  });
@@ -401,7 +416,7 @@
  moveDownItem.textContent = '向下移动';
  moveDownItem.style.cursor = 'pointer';
  moveDownItem.addEventListener('click', () => {
    moveRect(layoutIndex, rectIndex, 'down');
    moveRect(layoutIndex, rectIndex, 'up');
    document.body.removeChild(contextMenu);
  });
@@ -617,7 +632,7 @@
    if (Math.abs(glassDetail.y - otherRect.y) < threshold) {
      glassDetail.y = Math.round((glassDetail.y + otherRect.y) / 2);
    }
    // 垂直对齐下边缘
    // 垂直对齐上边缘
    if (Math.abs((glassDetail.y + glassDetail.height) - (otherRect.y + otherRect.height)) < threshold) {
      glassDetail.y = Math.round((otherRect.y + otherRect.height - glassDetail.height));
    }
@@ -947,7 +962,7 @@
//向上移动计算坐标
const getAvailableSpaceUp = (glassDetail, layout, obstacles) => {
  let maxSpace = layout.height - (glassDetail.y + glassDetail.height);
  let maxSpace = layout.height - glassDetail.y - glassDetail.height;
  obstacles.forEach(obstacle => {
    if (obstacle.y > glassDetail.y + glassDetail.height &&
        obstacle.x <= glassDetail.x + glassDetail.width &&
@@ -1013,7 +1028,7 @@
      event.preventDefault();
      if (!moveInterval) {
        moveInterval = setInterval(() => {
          moveRect(layoutIndex, rectIndex, 'up');
          moveRect(layoutIndex, rectIndex, 'down');
        }, 50);
      }
      break;
@@ -1021,7 +1036,7 @@
      event.preventDefault();
      if (!moveInterval) {
        moveInterval = setInterval(() => {
          moveRect(layoutIndex, rectIndex, 'down');
          moveRect(layoutIndex, rectIndex, 'up');
        }, 50);
      }
      break;