于杰
2025-09-28 baf74fc6ba071853f6bcb23150bb19d5ba872b39
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>