From 918c870a2bc093f22b6e80e7ed447aba0b161f4a Mon Sep 17 00:00:00 2001 From: ZengTao <2773468879@qq.com> Date: 星期四, 08 八月 2024 14:28:57 +0800 Subject: [PATCH] 修改打印数据格式,下面界面实现打印功能 --- UI-Project/src/views/UnLoadGlass/loadmachinerack.vue | 79 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 76 insertions(+), 3 deletions(-) diff --git a/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue b/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue index a6b9c45..6f7522a 100644 --- a/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue +++ b/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue @@ -13,6 +13,7 @@ import request from "@/utils/request"; import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService'; import { WebSocketHost, host } from '@/utils/constants' +import PrintFlow from './PrintFlow.vue' const dialogFormVisiblea = ref(false) const dialogFormVisiblea2 = ref(false) const dialogFormVisibleaDownGlass = ref(false) @@ -30,6 +31,9 @@ const timeRange = ref(["2022-01-01", "2025-01-01"]) const selectValuesa = reactive({}); const selectOptionsa = ref([]); +const dialogTableVisible = ref(false) +const printFlowCardId = ref('') +const printLayer=ref('') const handleInputChangea = (value, rowId) => { // 鏇存柊瀵瑰簲琛岀殑 select 鍊� @@ -230,8 +234,55 @@ } -const open=async()=>{ - router.push({path: '/UnLoadGlass/PrintFlow'}) +const open=async(row)=>{ + + printFlowCardId.value=row.flowCardId; + printLayer.value=row.layer + dialogTableVisible.value = true; + setTimeout(() => { + printFlowCard(); // 鏇挎崲鎴愪綘瑕佹墽琛岀殑鍑芥暟鍚� + }, 1000); + ; +} + +const printFlowCard = () => { + // 闇�瑕佹墦鍗扮殑灞�閮ㄥ尯鍩熻祴浜�"print-wrap"鐨刬d + let el = document.getElementById("child"); + let doc = document; + let body = doc.body || doc.getElementsByTagName("body")[0]; + let printId = "print-" + Date.now(); + + // 鍒涘缓鏃犲壇浣滅敤鐨勬墦鍗板鍣�(鍥犱笉纭畾椤甸潰鐨勬墦鍗板厓绱犳湁鏃犲叾瀹冩牱寮�) + let content = doc.createElement("div"); + content.id = printId; + + // 鏍峰紡鎺у埗涓庢墦鍗版棤鍏崇殑鍏冪礌闅愯棌 + let style = doc.createElement("style"); + style.innerHTML = + "body>#" + + printId + + "{display:none}@media print{" + + "@page {" + + " size: auto; " + + " margin: 2mm 2mm 0mm 1mm; " + + " }body>:not(#" + + printId + + "){display:none !important}body>#" + + printId + + "{display:block;padding-top:1px}}"; + // + content.innerHTML = el.outerHTML; + // // console.log("el.outerHTML", el.outerHTML); + body.appendChild(style); + + // 涓巗tyle鍏冪礌璁剧疆鐨勬牱寮忕浉閰嶅悎 + // 鎶婃墦鍗板唴瀹圭殑鍏冪礌娣诲姞鍒癰ody(浣滀负body鐨勫瓙鍏冪礌锛屽彲鐢╞ody鐨勫瓙閫夋嫨鍣� '>' 鎺у埗鎵撳嵃鏍峰紡) + body.appendChild(content); + setTimeout(() => { + window.print(); + body.removeChild(content); + body.removeChild(style); + }, 20); } @@ -273,7 +324,7 @@ @click="handleBindRack(scope.row)">{{ $t('reportWork.bindingshelves') }}</el-button> <el-button size="mini" type="text" plain @click="handleBindRack2(scope.row)">{{ $t('reportWork.clear') }}</el-button> - <el-button @click="open()">111</el-button> + <el-button @click="open(scope.row)" :disabled="scope.row.flowCardId==null">鎵撳嵃</el-button> </template> </el-table-column> @@ -377,6 +428,22 @@ </div> </template> </el-dialog> + + <el-dialog + id="sizePrintCalrd" + v-model="dialogTableVisible" + destroy-on-close + style="width: 75%;height:75% "> + <!-- <template #header="{ close, titleId, titleClass }"> + <el-button @click="printFlowCard" >鎵撳嵃</el-button> + </template> --> + <print-flow + id="child" + :printFlowCardId="printFlowCardId" + :printLayer="printLayer" + style="width: 100%;height: 100%"/> + </el-dialog> + </template> <style scoped> #dt { @@ -421,4 +488,10 @@ margin-top: -40px; margin-left: 100px; } + +:deep(#sizePrintCalrd .el-dialog__body) { + height: 85%; + width: 100%; + overflow-y: auto; +} </style> \ No newline at end of file -- Gitblit v1.8.0