| | |
| | | <template> |
| | | <div> |
| | | <el-button id="button" type="primary" @click="printReports" style="background: #409eff; position: fixed; top: 90px; right: 100px; padding: 20px; color: white; border: none; cursor: pointer; margin-right: 10px;"> |
| | | 预览 |
| | | </el-button> |
| | | <el-button id="button" type="primary" @click="handlePrint" style="position: fixed; top: 90px; right: 20px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;"> |
| | | 打印 |
| | | </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.plain"> |
| | | 切材率 |
| | | <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.type" style="width: 120px;"> |
| | | <el-option v-for="type in linkTypes" :key="type" :value="type" /> |
| | | <el-select v-model="config.columnTypes" style="width: 120px;"> |
| | | <el-option v-for="type in columnTypes" :key="type" :value="type" /> |
| | | </el-select> |
| | | <el-button id="button" type="primary" @click="handlePrint" style="background: #409eff; color: white; border: none; cursor: pointer;"> |
| | | 预览 |
| | | </el-button> |
| | | <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 ref="printContainer" style="position: relative;"> |
| | |
| | | import { ref, onMounted, watch, reactive, inject } from 'vue'; |
| | | import RectRenderer from './page/RectRenderer.vue'; |
| | | import request from "@/utils/request"; |
| | | import {ElMessage, ElMessageBox} from "element-plus"; |
| | | import requestOptimize from "@/utils/requestOptimize"; |
| | | |
| | | const props = defineProps({ |
| | | project : null, |
| | |
| | | const savedProjectNo = localStorage.getItem('projectNo'); |
| | | const processId = ref(''); |
| | | 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 linkTypes = ['一列', '两列', '三列'] |
| | | const columnTypes = ['一列', '两列', '三列', '四列'] |
| | | const rowTypes = ['一行', '两行'] |
| | | const glassInfo = ['不显示', '显示在右侧', '显示在下侧'] |
| | | const cutInfo = ['不显示', '显示'] |
| | | |
| | | // 定义不同布局对应的尺寸 |
| | | const layoutDimensions = { |
| | |
| | | const currentPrintHeight = ref(layoutDimensions[printLayout.value].height); |
| | | |
| | | const selectLayout = () => { |
| | | request.post(`/glassOptimize/selectOptimizeResult/${processId.value}`) |
| | | request.post(`/glassOptimize/getOptimizeInfo/${processId.value}`) |
| | | .then((res) => { |
| | | if (res.code == 200) { |
| | | try { |
| | | layoutData.value = JSON.parse(res.data.data[0].Layouts); |
| | | materialDetails.value=res.data.optimizeUse; |
| | | dataLoaded.value=true; |
| | | layoutData.value = res.data.layouts; |
| | | optimizeUse.value=res.data.optimizeUse[0]; |
| | | // 添加控制台输出 |
| | | console.log('layoutData:', layoutData.value); |
| | | console.log('optimizeUse:', optimizeUse.value); |
| | | } catch (error) { |
| | | console.error("解析布局数据失败:", error); |
| | | } |
| | |
| | | }); |
| | | }; |
| | | |
| | | const selectReportData= () => { |
| | | request.post(`/glassOptimize/getReportData/${processId.value}`) |
| | | .then((res) => { |
| | | if (res.code == 200) { |
| | | try { |
| | | reportData.value = res.data.reportData[0]; |
| | | console.log('reportData:', reportData.value); |
| | | } catch (error) { |
| | | console.error("解析布局数据失败:", error); |
| | | } |
| | | } else { |
| | | console.error("请求失败,状态码:", res.code); |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | console.error("请求失败:", error); |
| | | }); |
| | | }; |
| | | |
| | | |
| | | const selectMaterialData= () => { |
| | | request.post(`/glassOptimize/materialInfo/${processId.value}`) |
| | | .then((res) => { |
| | | if (res.code == 200) { |
| | | try { |
| | | materialList.value = res.data.materialList[0]; |
| | | console.log('reportData:', materialList.value); |
| | | } catch (error) { |
| | | console.error("解析布局数据失败:", error); |
| | | } |
| | | } else { |
| | | console.error("请求失败,状态码:", res.code); |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | console.error("请求失败:", error); |
| | | }); |
| | | }; |
| | | |
| | | const selectProductData= () => { |
| | | request.post(`/glassOptimize/getProductList/${processId.value}`) |
| | | .then((res) => { |
| | | if (res.code == 200) { |
| | | try { |
| | | productList.value = res.data.productList; |
| | | console.log('productList:', productList.value); |
| | | } catch (error) { |
| | | console.error("解析布局数据失败:", error); |
| | | } |
| | | } else { |
| | | console.error("请求失败,状态码:", res.code); |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | console.error("请求失败:", error); |
| | | }); |
| | | }; |
| | | |
| | | const printReports = async() => { |
| | | try { |
| | | // 确保有数据可以提交 |
| | | if (!processId) { |
| | | ElMessage.warning('没有可打印的数据'); |
| | | return; |
| | | } |
| | | |
| | | // 映射 rowTypes 到 layoutRows |
| | | const layoutRowsMap = { |
| | | '一行': 1, |
| | | '两行': 2 |
| | | }; |
| | | |
| | | // 映射 columnTypes 到 layoutColumns |
| | | const layoutColumnsMap = { |
| | | '一列': 1, |
| | | '两列': 2, |
| | | '三列': 3, |
| | | '四列': 4 |
| | | }; |
| | | |
| | | // 映射 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, |
| | | companyName : '1', |
| | | glassThickness : optimizeUse.value.thickness, |
| | | glassType : optimizeUse.value.model, |
| | | quantity : String(optimizeUse.value.processingQuantity), |
| | | printLayouts : config.printLayouts ? '1' : '0', |
| | | printReport : config.printReport ? '1' : '0', |
| | | layouts : layoutData.value, |
| | | reportData: reportData.value, |
| | | materialList: materialList.value, |
| | | productList: productList.value, |
| | | layoutSet: { |
| | | layoutRows: layoutRowsMap[config.rowTypes] || 1, |
| | | layoutColumns: layoutColumnsMap[config.columnTypes] || 1, |
| | | glassInfoShow: glassInfoMap[config.glassInfo] || 0, |
| | | cutInfoShow: cutInfoMap[config.cutInfo] || 0 |
| | | } |
| | | |
| | | }, { |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | | } |
| | | }); |
| | | |
| | | } catch (error) { |
| | | console.error('保存失败:', error); |
| | | ElMessage.error('保存失败,请稍后再试'); |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | const config = reactive({ |
| | | type: '两列', |
| | | columnTypes: '两列', |
| | | rowTypes: '两行', |
| | | plain: true, |
| | | printLayouts: true, |
| | | printReport: true, |
| | | glassInfo: '不显示', |
| | | cutInfo: '显示' |
| | | |
| | | }) |
| | | |
| | | onMounted(() => { |
| | |
| | | |
| | | if (processId.value) { |
| | | selectLayout(); |
| | | selectReportData(); |
| | | selectMaterialData(); |
| | | selectProductData(); |
| | | } |
| | | }); |
| | | |