From a660db06773007b1be690e0674829c00a57aeb7b Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期三, 24 十二月 2025 16:21:23 +0800
Subject: [PATCH] 订单首页流程卡新增楼层编号显示
---
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/OptimizationRectPrint.vue | 285 +++++++++++++++++++++++++++++---------------------------
1 files changed, 148 insertions(+), 137 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 f5d89be..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,47 +1,48 @@
<template>
<div>
- <el-button id="button" type="primary" @click="previewReport" style="position: fixed; top: 90px; right: 40px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;">
- 棰勮
- </el-button>
-<!-- <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
+ id="button"
+ type="primary"
+ @click="previewReport"
+ :loading="loading" style="position: fixed; top: 90px; right: 40px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;"
+ :disabled="loading">
+ {{ loading ? '鐢熸垚涓�...' : '棰勮' }}
+ </el-button>
<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" style="margin-top: 20px;">
+ <div v-if="pdfUrl || pdfLoading" style="margin-top: 20px;">
+ <!-- PDF鍔犺浇鏃舵樉绀虹編鍖栧悗鐨勫姞杞藉姩鐢� -->
+ <div v-if="pdfLoading" style="display: flex; justify-content: center; align-items: center; height: 800px; border: 1px solid #ddd; background-color: #f5f5f5;">
+ <div style="text-align: center;">
+ <div class="loading-animation">
+ <div class="dot-flashing"></div>
+ </div>
+ <p style="margin-top: 20px; font-size: 18px; color: #666;">PDF鏂囨。鍔犺浇涓�...</p>
+ <p style="font-size: 14px; color: #999; margin-top: 10px;">姝e湪涓烘偍鍑嗗棰勮鍐呭</p>
+ </div>
+ </div>
+ <!-- PDF鍔犺浇瀹屾垚鏃舵樉绀篜DF -->
<iframe
- :src="pdfUrl"
- style="width: 100%; height: 800px; border: 1px solid #ddd;"
+ v-else
+ :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;">
@@ -70,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,
@@ -82,18 +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('');
@@ -152,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}`)
@@ -199,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,
@@ -233,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,
@@ -247,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
}
}, {
@@ -273,7 +278,7 @@
}
};
-const printReport = async () => {
+const printReports = async () => {
try {
await generateReport();
if (!filePath.value) {
@@ -393,12 +398,18 @@
const previewReport = async () => {
try {
+ loading.value = true;
+ ElMessage.info('姝e湪鐢熸垚鎶ュ憡锛岃绋嶅��...')
await generateReport();
if (!filePath.value) {
ElMessage.error('鏈敹鍒版湁鏁堢殑PDF鏂囦欢璺緞');
+ loading.value = false;
return;
}
const encodedFilePath = encodeURIComponent(filePath.value);
+
+ // 璁剧疆PDF鍔犺浇鐘舵�佷负true
+ pdfLoading.value = true;
const response = await request.get('/glassOptimize/reports/pdf', {
params: { filePath: encodedFilePath },
@@ -411,6 +422,8 @@
// 妫�鏌ュ搷搴旀暟鎹槸鍚﹀瓨鍦ㄤ笖鏈夋晥
if (!response) {
ElMessage.error('鏈兘鑾峰彇鍒癙DF鏁版嵁');
+ loading.value = false;
+ pdfLoading.value = false; // 璁剧疆PDF鍔犺浇鐘舵�佷负false
return;
}
@@ -419,6 +432,8 @@
// 妫�鏌� blob 鏄惁鏈夋晥
if (blob.size === 0) {
ElMessage.error('鎺ユ敹鍒扮┖鐨凱DF鏂囦欢');
+ loading.value = false;
+ pdfLoading.value = false; // 璁剧疆PDF鍔犺浇鐘舵�佷负false
return;
}
@@ -427,12 +442,17 @@
pdfUrl.value = url;
ElMessage.success('鎶ュ憡鐢熸垚鎴愬姛锛屾鍦ㄩ瑙�...');
+ loading.value = false;
- // 鍙�夛細娣诲姞娓呯悊鏈哄埗锛屽綋缁勪欢鍗歌浇鏃舵竻鐞哢RL
- // 杩欓噷鍙互浣跨敤 onUnmounted 閽╁瓙杩涜娓呯悊
+ // 寤惰繜涓�灏忔鏃堕棿鍚庤缃甈DF鍔犺浇瀹屾垚锛岀‘淇濈敤鎴疯兘鐪嬪埌鍔犺浇鐘舵��
+ setTimeout(() => {
+ pdfLoading.value = false;
+ }, 500);
+
} catch (error) {
console.error('棰勮娴佺▼寮傚父:', error);
-
+ loading.value = false;
+ pdfLoading.value = false; // 璁剧疆PDF鍔犺浇鐘舵�佷负false
if (error.response) {
const status = error.response.status;
if (status === 400) {
@@ -449,70 +469,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: '涓ゅ垪',
@@ -541,7 +497,9 @@
selectReportData();
selectMaterialData();
selectProductData();
+ fetchSettings(username);
}
+
});
const handlePrint = () => {
@@ -568,3 +526,56 @@
handleLayoutChange();
});
</script>
+
+<style scoped>
+.loading-animation {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+.dot-flashing {
+ position: relative;
+ width: 10px;
+ height: 10px;
+ border-radius: 5px;
+ background-color: #409eff;
+ color: #409eff;
+ animation: dotFlashing 1s infinite linear alternate;
+ animation-delay: .5s;
+}
+
+.dot-flashing::before, .dot-flashing::after {
+ content: '';
+ display: inline-block;
+ position: absolute;
+ top: 0;
+ width: 10px;
+ height: 10px;
+ border-radius: 5px;
+ background-color: #409eff;
+ color: #409eff;
+}
+
+.dot-flashing::before {
+ left: -15px;
+ animation: dotFlashing 1s infinite alternate;
+ animation-delay: 0s;
+}
+
+.dot-flashing::after {
+ left: 15px;
+ animation: dotFlashing 1s infinite alternate;
+ animation-delay: 1s;
+}
+
+@keyframes dotFlashing {
+ 0% {
+ background-color: #409eff;
+ }
+ 50%,
+ 100% {
+ background-color: #c0d9f7;
+ }
+}
+</style>
\ No newline at end of file
--
Gitblit v1.8.0