From f7a2fcdda7f1120498c5c5f75c5a99955fc54b43 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期二, 16 十二月 2025 16:54:09 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override
---
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/OptimizationRectPrint.vue | 183 +++++++++++++--------------------------------
1 files changed, 54 insertions(+), 129 deletions(-)
diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/OptimizationRectPrint.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/OptimizationRectPrint.vue
index e34c8d2..6b19094 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/OptimizationRectPrint.vue
+++ b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/OptimizationRectPrint.vue
@@ -1,6 +1,6 @@
<template>
<div>
-<!-- <el-button id="button" type="primary" @click="printReport" style="position: fixed; top: 90px; right: 20px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;">-->
+<!-- <el-button id="button" type="primary" @click="printReports" style="position: fixed; top: 90px; right: 20px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;">-->
<!-- 鎵撳嵃-->
<!-- </el-button>-->
<el-button
@@ -15,30 +15,6 @@
<div style="display: flex; align-items: center; gap: 20px; margin-bottom: 20px;">
<span>宸ョ▼缂栧彿锛�</span>
<el-input readonly placeholder="" style="width: 150px" v-model="processId"></el-input>
- <el-checkbox v-model="config.printLayouts">
- 鎵撳嵃鐗堝浘
- </el-checkbox>
- <el-checkbox v-model="config.printReport">
- 鎵撳嵃鎶ュ憡
- </el-checkbox>
- <div style="margin-right: 30px;"></div>
- <span>甯冨眬閫夋嫨锛�</span>
- <el-select v-model="config.columnTypes" style="width: 120px;">
- <el-option v-for="type in columnTypes" :key="type" :value="type" />
- </el-select>
- <el-select v-model="config.rowTypes" style="width: 120px;">
- <el-option v-for="type in rowTypes" :key="type" :value="type" />
- </el-select>
- </div>
- <div style="display: flex; align-items: center; gap: 20px; margin-bottom: 20px;">
- <span>鏄剧ず灏忕墖淇℃伅锛�</span>
- <el-select v-model="config.glassInfo" style="width: 120px;">
- <el-option v-for="type in glassInfo" :key="type" :value="type" />
- </el-select>
- <span>鏄剧ず鍒囧壊淇℃伅锛�</span>
- <el-select v-model="config.cutInfo" style="width: 120px;">
- <el-option v-for="type in cutInfo" :key="type" :value="type" />
- </el-select>
</div>
<div v-if="pdfUrl || pdfLoading" style="margin-top: 20px;">
@@ -55,9 +31,18 @@
<!-- PDF鍔犺浇瀹屾垚鏃舵樉绀篜DF -->
<iframe
v-else
- :src="pdfUrl" style="width: 100%; height: 800px; border: 1px solid #ddd;"
+ :src="pdfUrl" style="width: 100%; height: 780px; border: 1px solid #ddd;"
title="PDF棰勮">
</iframe>
+ </div>
+
+ <div v-else style="margin-top: 20px;">
+ <div style="display: flex; justify-content: center; align-items: center; height: 780px; border: 1px solid #ddd; background-color: white;">
+ <div style="text-align: center; color: #999;">
+ <p style="font-size: 20px; margin-bottom: 10px;">浼樺寲鎶ュ憡棰勮鍖�</p>
+ <p style="font-size: 14px;">鐐瑰嚮涓婃柟"棰勮"鎸夐挳鐢熸垚骞舵煡鐪嬩紭鍖栨姤鍛�</p>
+ </div>
+ </div>
</div>
<div ref="printContainer" style="position: relative;">
@@ -86,6 +71,9 @@
import request from "@/utils/request";
import {ElMessage, ElMessageBox} from "element-plus";
import requestOptimize from "@/utils/requestOptimize";
+import useUserInfoStore from "@/stores/userInfo";
+
+const userStore = useUserInfoStore();
const props = defineProps({
project : null,
@@ -98,20 +86,22 @@
const layoutData = ref();
const optimizeUse = ref();
const reportData = ref();
-const layoutSet = ref();
const materialList = ref();
const productList = ref();
const dataLoaded = ref(false);
const materialDetails = ref();
const injectedProjectNo = inject('projectNo', null);
const state = ref();
-const columnTypes = ['涓�鍒�', '涓ゅ垪']
-const rowTypes = ['涓�琛�', '涓よ', '涓夎', '鍥涜']
-const glassInfo = ['涓嶆樉绀�', '鏄剧ず鍦ㄥ彸渚�', '鏄剧ず鍦ㄤ笅渚�']
-const cutInfo = ['涓嶆樉绀�', '鏄剧ず']
const filePath = ref('');
const loading = ref(false);
const pdfLoading = ref(false);
+const printLayouts = ref();
+const printReport = ref();
+const layoutRows = ref();
+const layoutColumns = ref();
+const glassInfoShow = ref();
+const cutInfoShow = ref();
+const username = userStore.user.userName;
const pdfUrl = ref('');
@@ -170,6 +160,30 @@
});
};
+const fetchSettings = async (username) => {
+ try {
+ const response = await request.post(`/glassOptimize/selectOptimizeParms/${username}`);
+ if (response.code == 200) {
+ if (!response.data) {
+ console.error('鍝嶅簲鏁版嵁涓虹┖');
+ return;
+ }
+ const parsedData = JSON.parse(response.data);
+ console.log('璁剧疆鍐呭:', parsedData);
+ printLayouts.value = parsedData.server.printLayouts;
+ printReport.value = parsedData.server.printReport;
+ layoutRows.value = parsedData.server.layoutRows;
+ layoutColumns.value = parsedData.server.layoutColumns;
+ glassInfoShow.value = parsedData.server.glassInfoShow;
+ cutInfoShow.value = parsedData.server.cutInfoShow;
+ } else {
+ console.error('璇锋眰澶辫触锛岀姸鎬佺爜:', response.code);
+ }
+ } catch (error) {
+ console.error('璇锋眰鍙戠敓閿欒:', error);
+ }
+};
+
const selectMaterialData= () => {
request.post(`/glassOptimize/materialInfo/${processId.value}`)
@@ -217,33 +231,6 @@
return;
}
- // 鏄犲皠 rowTypes 鍒� layoutRows
- const layoutRowsMap = {
- '涓�琛�': 1,
- '涓よ': 2,
- '涓夎': 3,
- '鍥涜': 4
- };
-
- // 鏄犲皠 columnTypes 鍒� layoutColumns
- const layoutColumnsMap = {
- '涓�鍒�': 1,
- '涓ゅ垪': 2,
- };
-
- // 鏄犲皠 glassInfo 鍒� glassInfoShow
- const glassInfoMap = {
- '涓嶆樉绀�': 0,
- '鏄剧ず鍦ㄥ彸渚�': 1,
- '鏄剧ず鍦ㄤ笅渚�': 2
- };
-
- // 鏄犲皠 cutInfo 鍒� cutInfoShow
- const cutInfoMap = {
- '涓嶆樉绀�': 0,
- '鏄剧ず': 1
- };
-
const response = await requestOptimize.post('/api/reports', {
fileName: processId.value,
projectNo: processId.value,
@@ -251,8 +238,8 @@
glassThickness : optimizeUse.value.thickness,
glassType : optimizeUse.value.model,
quantity : String(optimizeUse.value.processingQuantity),
- printLayouts : config.printLayouts ? '1' : '0',
- printReport : config.printReport ? '1' : '0',
+ printLayouts : printLayouts.value || '0',
+ printReport : printReport.value || '0',
layouts : layoutData.value,
reportData:{
rectangleQuantity: reportData.value.rectangleQuantity,
@@ -265,10 +252,10 @@
productList: productList.value,
},
layoutSet: {
- layoutRows: layoutRowsMap[config.rowTypes] || 1,
- layoutColumns: layoutColumnsMap[config.columnTypes] || 1,
- glassInfoShow: glassInfoMap[config.glassInfo] || 0,
- cutInfoShow: cutInfoMap[config.cutInfo] || 0
+ layoutRows: parseInt(layoutRows.value) || 2,
+ layoutColumns: parseInt(layoutColumns.value) || 2,
+ glassInfoShow: parseInt(glassInfoShow.value) || 0,
+ cutInfoShow: parseInt(cutInfoShow.value) || 0
}
}, {
@@ -291,7 +278,7 @@
}
};
-const printReport = async () => {
+const printReports = async () => {
try {
await generateReport();
if (!filePath.value) {
@@ -483,70 +470,6 @@
}
};
-// const autoPreviewReport = async () => {
-// try {
-// await generateReport();
-// if (!filePath.value) {
-// // 濡傛灉娌℃湁鏂囦欢璺緞锛屼笉鎵ц棰勮
-// return;
-// }
-// const encodedFilePath = encodeURIComponent(filePath.value);
-//
-// const response = await request.get('/glassOptimize/reports/pdf', {
-// params: { filePath: encodedFilePath },
-// responseType: 'blob',
-// headers: {
-// 'Accept': 'application/pdf'
-// }
-// });
-//
-// // 妫�鏌ュ搷搴旀暟鎹槸鍚﹀瓨鍦ㄤ笖鏈夋晥
-// if (!response) {
-// ElMessage.error('鏈兘鑾峰彇鍒癙DF鏁版嵁');
-// return;
-// }
-//
-// const blob = new Blob([response], { type: 'application/pdf' });
-//
-// // 妫�鏌� blob 鏄惁鏈夋晥
-// if (blob.size === 0) {
-// ElMessage.error('鎺ユ敹鍒扮┖鐨凱DF鏂囦欢');
-// return;
-// }
-//
-// // 鍒涘缓PDF URL骞惰祴鍊肩粰 pdfUrl 鐢ㄤ簬鐣岄潰鏄剧ず
-// const url = URL.createObjectURL(blob);
-// pdfUrl.value = url;
-//
-// } catch (error) {
-// console.error('鑷姩棰勮娴佺▼寮傚父:', error);
-// }
-// };
-//
-// onMounted(() => {
-// // 浼樺厛浣跨敤娉ㄥ叆鐨� projectNo锛屽叾娆′娇鐢� props锛屾渶鍚庝娇鐢� localStorage
-// if (injectedProjectNo) {
-// processId.value = injectedProjectNo.value || injectedProjectNo;
-// } else if (props.project) {
-// processId.value = props.project.projectNumber || '';
-// state.value = props.state;
-// } else if (savedProjectNo) {
-// processId.value = savedProjectNo;
-// }
-//
-// if (processId.value) {
-// selectLayout();
-// selectReportData();
-// selectMaterialData();
-// selectProductData();
-//
-// // 鏁版嵁鍔犺浇瀹屾垚鍚庤嚜鍔ㄩ瑙�
-// setTimeout(() => {
-// autoPreviewReport();
-// }, 1000); // 寤惰繜1绉掔‘淇濇墍鏈夋暟鎹姞杞藉畬鎴�
-// }
-// });
-
const config = reactive({
columnTypes: '涓ゅ垪',
rowTypes: '涓よ',
@@ -574,7 +497,9 @@
selectReportData();
selectMaterialData();
selectProductData();
+ fetchSettings(username);
}
+
});
const handlePrint = () => {
--
Gitblit v1.8.0