north-glass-erp/northglass-erp/src/views/pp/glassOptimize/OptimizeControl.vue
@@ -21,7 +21,7 @@ import RectRenderer from './page/RectRenderer.vue'; import request from "@/utils/request"; import { useI18n } from "vue-i18n"; import { ElMessage } from "element-plus"; import {ElMessage, ElMessageBox} from "element-plus"; import requestOptimize from "@/utils/requestOptimize"; import useUserInfoStore from "@/stores/userInfo"; @@ -180,41 +180,45 @@ const response = await requestOptimize.post('api/cutFiles', { fileName: processId, projectNo: processId, glassThickness:inventoryData.value[0].thickness, glassType:inventoryData.value[0].model, glassThickness: inventoryData.value[0].thickness, glassType: inventoryData.value[0].model, quantity: inventoryData.value[0].processingQuantity, fileType:"OPT", fileSaveMode:fileMode.value, glassIdMode:glassIdMode.value, haveMark:haveMark.value, haveOptimaMark:haveOptimaMark.value, haveQMark:haveQMark.value, optimaMarkPosition:optimaMarkPosition.value, optimaMarkName:optimaMarkName.value, optimaMarkWidth:optimaMarkWidth.value, optimaMarkHeight:optimaMarkHeight.value, fileType: "OPT", fileSaveMode: fileMode.value, glassIdMode: glassIdMode.value, haveMark: haveMark.value, haveOptimaMark: haveOptimaMark.value, haveQMark: haveQMark.value, optimaMarkPosition: optimaMarkPosition.value, optimaMarkName: optimaMarkName.value, optimaMarkWidth: optimaMarkWidth.value, optimaMarkHeight: optimaMarkHeight.value, layouts: optimizeLayouts.value.layouts }, { headers: { 'Content-Type': 'application/json' }, responseType: 'blob' } }); // 处理下载 const downloadUrl = window.URL.createObjectURL(response); const a = document.createElement('a'); a.href = downloadUrl; a.download = 'output.opt'; document.body.appendChild(a); a.click(); document.body.removeChild(a); window.URL.revokeObjectURL(downloadUrl); ElMessage.success('OPT文件保存成功'); // 使用 MessageBox 显示文件保存位置信息 if (response.data && response.data.length > 0) { const filePath = response.data[0]; ElMessageBox.alert(`OPT文件保存成功,位置:${filePath}`, '保存成功', { confirmButtonText: '确定', type: 'success', dangerouslyUseHTMLString: true }); } else { ElMessageBox.alert('OPT文件保存成功', '保存成功', { confirmButtonText: '确定', type: 'success' }); } } catch (error) { console.error('保存失败:', error); ElMessage.error('保存失败,请稍后再试'); } }; </script> north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
@@ -80,9 +80,9 @@ <script setup> import { ref, reactive, onMounted, onUnmounted } from 'vue'; import { useRouter } from 'vue-router'; // 添加这行 import { useRouter } from 'vue-router'; import request from "@/utils/request"; const router = useRouter(); // 添加这行 const router = useRouter(); import { useI18n } from "vue-i18n"; import { ElMessage, ElMessageBox } from "element-plus"; import useUserInfoStore from "@/stores/userInfo"; @@ -553,6 +553,11 @@ 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 @@ -583,6 +588,18 @@ 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; }); } dragStartPos.value = { x: event.clientX, y: event.clientY @@ -819,6 +836,22 @@ } if (isValidRotation) { // 更新glassPoint坐标(如果存在) if (glassDetail.glassPoint && Array.isArray(glassDetail.glassPoint)) { // 保存原始点坐标 const originalPoints = JSON.parse(JSON.stringify(glassDetail.glassPoint)); // 旋转点坐标(以矩形左上角为原点的旋转) glassDetail.glassPoint.forEach((point, index) => { // 计算相对于矩形左上角的坐标 const relX = originalPoints[index].X - originalState.x; const relY = originalPoints[index].Y - originalState.y; // 旋转90度后的坐标(顺时针) point.X = originalState.x + relY; point.Y = originalState.y + (originalState.width - relX); }); } adjustGrayRectangles(layoutIndex); } else { glassDetail.width = originalState.width; @@ -882,6 +915,11 @@ return; } // 保存原始坐标 const originalX = glassDetail.x; const originalY = glassDetail.y; switch (direction) { case 'up': glassDetail.y += maxStep; @@ -913,6 +951,16 @@ } if (isValidMove) { // 更新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; }); } adjustGrayRectangles(layoutIndex); } else { glassDetail.x = originalState.x; @@ -1161,6 +1209,13 @@ // 更新矩形位置 glassDetail.x = newX; glassDetail.y = newY; // 更新glassPoint坐标 if (glassDetail.glassPoint && Array.isArray(glassDetail.glassPoint)) { glassDetail.glassPoint.forEach(point => { point.X = width - point.X; }); } }); // 更新布局 @@ -1181,6 +1236,13 @@ // 更新矩形位置 glassDetail.y = newY; // 更新glassPoint坐标 if (glassDetail.glassPoint && Array.isArray(glassDetail.glassPoint)) { glassDetail.glassPoint.forEach(point => { point.Y = height - point.Y; }); } }); // 更新布局 north-glass-erp/northglass-erp/src/views/sd/order/CreateOrder.vue
@@ -906,7 +906,7 @@ titleUploadData.value['version'] = null } if(history.state.type=='copyTitle'){ gridOptions.menuConfig.body.options[0][11].disabled = tru gridOptions.menuConfig.body.options[0][11].disabled = true titleUploadData.value['version'] = null } north-glass-erp/src/main/java/com/example/erp/service/pp/GlassOptimizeService.java
@@ -393,6 +393,24 @@ } } } // 处理 glassPoint 序列化 if (detail.containsKey("glassPoint")) { Object glassPointObj = detail.get("glassPoint"); if (glassPointObj != null) { try { // 如果 glassPointObj 已经是字符串,则不需要转换 if (!(glassPointObj instanceof String)) { // 将对象转换为 JSON 字符串 String glassPointStr = mapper.writeValueAsString(glassPointObj); detail.put("glassPoint", glassPointStr); } } catch (Exception e) { // 如果转换失败,记录错误并移除该字段 System.err.println("转换 glassPoint 失败: " + e.getMessage()); detail.remove("glassPoint"); } } } if (isRemain) { offCutDetails.add(detail); north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
@@ -1523,6 +1523,7 @@ <update id="updateNormalDetails"> UPDATE pp.optimize_detail SET glass_point = #{detail.glassPoint}, x_axis = #{detail.x}, y_axis = #{detail.y} WHERE