| | |
| | |
|
| | | <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";
|
| | |
| | | });
|
| | | 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'
|
| | |
| | | }).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);
|
| | | }
|
| | |
| | | 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',
|
| | |
| | | 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,
|
| | |
| | | moveUpAndRotateItem.textContent = '向上移动并旋转';
|
| | | moveUpAndRotateItem.style.cursor = 'pointer';
|
| | | moveUpAndRotateItem.addEventListener('click', () => {
|
| | | moveRectAndRotate(layoutIndex, rectIndex, 'up');
|
| | | moveRectAndRotate(layoutIndex, rectIndex, 'down');
|
| | | document.body.removeChild(contextMenu);
|
| | | });
|
| | |
|
| | |
| | | moveDownAndRotateItem.textContent = '向下移动并旋转';
|
| | | moveDownAndRotateItem.style.cursor = 'pointer';
|
| | | moveDownAndRotateItem.addEventListener('click', () => {
|
| | | moveRectAndRotate(layoutIndex, rectIndex, 'down');
|
| | | moveRectAndRotate(layoutIndex, rectIndex, 'up');
|
| | | document.body.removeChild(contextMenu);
|
| | | });
|
| | |
|
| | |
| | | moveUpItem.textContent = '向上移动';
|
| | | moveUpItem.style.cursor = 'pointer';
|
| | | moveUpItem.addEventListener('click', () => {
|
| | | moveRect(layoutIndex, rectIndex, 'up');
|
| | | moveRect(layoutIndex, rectIndex, 'down');
|
| | | document.body.removeChild(contextMenu);
|
| | | });
|
| | |
|
| | |
| | | moveDownItem.textContent = '向下移动';
|
| | | moveDownItem.style.cursor = 'pointer';
|
| | | moveDownItem.addEventListener('click', () => {
|
| | | moveRect(layoutIndex, rectIndex, 'down');
|
| | | moveRect(layoutIndex, rectIndex, 'up');
|
| | | document.body.removeChild(contextMenu);
|
| | | });
|
| | |
|
| | |
| | | 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));
|
| | | }
|
| | |
| | |
|
| | | //向上移动计算坐标
|
| | | 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 &&
|
| | |
| | | event.preventDefault();
|
| | | if (!moveInterval) {
|
| | | moveInterval = setInterval(() => {
|
| | | moveRect(layoutIndex, rectIndex, 'up');
|
| | | moveRect(layoutIndex, rectIndex, 'down');
|
| | | }, 50);
|
| | | }
|
| | | break;
|
| | |
| | | event.preventDefault();
|
| | | if (!moveInterval) {
|
| | | moveInterval = setInterval(() => {
|
| | | moveRect(layoutIndex, rectIndex, 'down');
|
| | | moveRect(layoutIndex, rectIndex, 'up');
|
| | | }, 50);
|
| | | }
|
| | | break;
|