| New file |
| | |
| | | <template>
|
| | | <div >
|
| | | <RectRenderer |
| | | :layoutData="layoutData" |
| | | :gw="1400" |
| | | :gh="1100" |
| | | style="width: 1500px; height: 800px; position: relative;"
|
| | | />
|
| | | |
| | | |
| | | </div>
|
| | | <button @click="submitLayouts" style="position: fixed; bottom: 20px; right: 20px; padding: 10px; background: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer;">
|
| | | 保存OPT
|
| | | </button>
|
| | | </template>
|
| | | |
| | | <script setup>
|
| | | import { ref,onMounted } from 'vue';
|
| | | import RectRenderer from './page/RectRenderer.vue';
|
| | | import mockLayoutData from '../../../components/pp/MockData';
|
| | | import request from "@/utils/request";
|
| | | import { useI18n } from "vue-i18n";
|
| | | import { ElMessage } from "element-plus";
|
| | |
|
| | | const { t } = useI18n();
|
| | | // const layoutData = ref(mockLayoutData);
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | const savedProjectNo = localStorage.getItem('projectNo');
|
| | | const processId = savedProjectNo;
|
| | | const layoutData = ref(null);
|
| | |
|
| | |
|
| | |
|
| | | const selectLayout = () => {
|
| | | request.post(`/glassOptimize/selectOptimizeResult/${processId}`)
|
| | | .then((res) => {
|
| | | if (res.code == 200) {
|
| | | try {
|
| | | const parsedData = JSON.parse(res.data.data[0].Layouts);
|
| | | layoutData.value = parsedData;
|
| | | } catch (error) {
|
| | | |
| | | |
| | | }
|
| | | } else {
|
| | |
|
| | | }
|
| | | })
|
| | | .catch((error) => {
|
| | | console.error("请求失败:", error);
|
| | | ElMessage.error(t('basicData.msg.requestFailed'));
|
| | | });
|
| | | }
|
| | |
|
| | | onMounted(() => {
|
| | | selectLayout();
|
| | |
|
| | | });
|
| | | |
| | | const submitLayouts = async () => {
|
| | | try {
|
| | | const response = await request.post('/glassOptimize/generateOpt', {
|
| | | Layouts: layoutData.value.Layouts |
| | | }, {
|
| | | headers: {
|
| | | 'Content-Type': 'application/json'
|
| | | },
|
| | | responseType: 'blob' // 以 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文件下载成功,请选择文件路径');
|
| | | } catch (error) {
|
| | | console.error('下载失败:', error);
|
| | | // 显示错误消息给用户
|
| | | ElMessage.error('下载失败,请稍后再试');
|
| | | }
|
| | | };
|
| | |
|
| | |
|
| | |
|
| | | </script>
|
| | | |