廖井涛
6 小时以前 f7a2fcdda7f1120498c5c5f75c5a99955fc54b43
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/OptimizePrint.vue
@@ -1,7 +1,9 @@
<script setup>
 const layout=[
   {"x":0,"y":0,"w":2,"h":2,"i":"0"},
   {"x":2,"y":0,"w":2,"h":4,"i":"1"},
 import {ref} from "vue";
 const layout=ref([
   {"x":0,"y":0,"w":50,"h":50,"i":"0"},
   /*{"x":2,"y":0,"w":2,"h":4,"i":"1"},
   {"x":4,"y":0,"w":2,"h":5,"i":"2"},
   {"x":6,"y":0,"w":2,"h":3,"i":"3"},
   {"x":8,"y":0,"w":2,"h":3,"i":"4"},
@@ -19,23 +21,43 @@
   {"x":8,"y":10,"w":2,"h":5,"i":"16"},
   {"x":10,"y":4,"w":2,"h":2,"i":"17"},
   {"x":0,"y":9,"w":2,"h":3,"i":"18"},
   {"x":2,"y":6,"w":2,"h":2,"i":"19"}
 ]
   {"x":2,"y":6,"w":2,"h":2,"i":"19"}*/
 ])
 const layoutUpdated = (newLayout) => {
   //checkLayoutBounds(newLayout)
 }
 const checkLayoutBounds = (layout1) => {
   layout1.forEach(item => {
     // 检查边界,例如确保x和y不小于0,并且w和h不超出最大值等。
     if (item.x < 0) item.x = 0;
     if (item.y < 0) item.y = 0;
     if (item.w > 12) item.w = 12; // 假设最大列数为12
     if (item.h > 10) item.h = 10; // 假设最大行为10(根据需要调整)
   });
   layout.value = layout1; // 应用边界检查后的布局
   console.log(layout1)
 }
 const moveEvent = (i, newX, newY) => {
   console.log(`移动元素 ${i} 到 (${newX}, ${newY})`)
 }
</script>
<template>
  <grid-layout
      style="border:1px solid black;height: 100%;width: 100%"
      style="border:1px solid black;height: 244px;width: 366px;overflow: hidden;grid-template-columns: 1px"
      :layout.sync="layout"
      :col-num="12"
      :row-height="30"
      :col-num="366"
      :row-height="1"
      :is-draggable="true"
      :is-resizable="false"
      :is-mirrored="false"
      :vertical-compact="true"
      :margin="[2, 2]"
      :margin="[0, 0]"
      :use-css-transforms="true"
      :autoSize="false"
      @layout-updated="layoutUpdated"
  >
    <grid-item v-for="item in layout"
@@ -45,6 +67,7 @@
               :h="item.h"
               :i="item.i"
               :key="item.i"
               @move="moveEvent"
               style="background-color: white"
    >
      {{item.i}}