From 56fab901b298857ff4985b7429ef843c9a9d1471 Mon Sep 17 00:00:00 2001 From: wangfei <3597712270@qq.com> Date: 星期三, 28 八月 2024 16:20:02 +0800 Subject: [PATCH] 钢化模块打印功能,新增表格字段 --- UI-Project/src/views/UnLoadGlass/loadmachinerack.vue | 123 ++++++++++++++++++++++++++++++++--------- 1 files changed, 96 insertions(+), 27 deletions(-) diff --git a/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue b/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue index 5463263..513c5a5 100644 --- a/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue +++ b/UI-Project/src/views/UnLoadGlass/loadmachinerack.vue @@ -6,6 +6,10 @@ import request from "@/utils/request"; import {closeWebSocket, initializeWebSocket} from '@/utils/WebSocketService'; import {host, WebSocketHost} from '@/utils/constants' +import PrintFlow from "@/views/UnLoadGlass/PrintFlow.vue"; +import Landingindication from "./Landingindication.vue"; +import Landingindicationtwo from "./Landingindicationtwo.vue"; +import PrintLabel from "@/views/UnLoadGlass/PrintCustomLabelSemi1.vue"; const router = useRouter() const {t} = useI18n() @@ -33,10 +37,12 @@ const selectValuesa = reactive({}); const selectOptionsa = ref([]); const dialogTableVisible = ref(false) +const dialogTableVisible1 = ref(false) const printFlowCardId = ref('') const printLayer = ref('') const now = new Date(); -const timeRange = ref([new Date(now.setHours(0, 0, 0, 0)), new Date(now.setHours(23, 59, 59, 999))]) +const timeRange = ref([]) +const browser=ref(false) const handleChange = async () => { console.log("瑙﹀彂寮�鍏�") @@ -59,7 +65,15 @@ console.error(error); } } - +const confirmBrowser = () =>{ + if (/chrome|chromium/i.test(navigator.userAgent) && !/edg/i.test(navigator.userAgent)) { + browser.value=true +} else if (/edg/i.test(navigator.userAgent)) { + browser.value=false +} else { + browser.value=false +} +} const handleInputChangea = (value, rowId) => { // 鏇存柊瀵瑰簲琛岀殑 select 鍊� @@ -104,7 +118,6 @@ flowCardId: firstPart, layer: twoPart }); - console.log(response) if (response.code == 200) { // 缁戝畾鎴愬姛锛屽鐞嗛�昏緫 console.log('缁戝畾鎴愬姛'); @@ -146,7 +159,7 @@ ElMessage.success(response.message); dialogFormVisiblea2.value = false; if(fullFlowCard.value==workFlowCard.value){ - fullFlowCard.value==""; + fullFlowCard.value=""; } } else if (response.code === 500) { // 娓呴櫎澶辫触鐨勯�昏緫 @@ -188,18 +201,17 @@ // 鏇存柊 tableData 鐨勬暟鎹� if (data.downGlassInfos != null) { - downGlass.value = data.downGlassInfos[0][1]; + downGlass.value = data.downGlassInfos[0]; } if (data.engineerIdList != null) { selectOptionsa.value = data.engineerIdList[0] } if (data.autoPrint != null) { - autoPrint.value = data.autoPrint; + autoPrint.value = data.autoPrint[0]; } - console.log(autoPrint.value) - tableData.splice(0, tableData.length, ...data.params[0]); - if (fullFlowCard.value == ""&&autoPrint.value==true) { + //鑷姩鎵撳嵃 + if (fullFlowCard.value == ""&&autoPrint.value==true&&browser.value==true) { for (let i = 0; i < tableData.length; i++) { if (tableData[i].totalQuantity != 0) { if (tableData[i].totalQuantity == tableData[i].racksNumber + tableData[i].otherNumber && fullFlowCard.value != tableData[i].flowCardId) { @@ -213,12 +225,15 @@ } } } - + if(data.params!=null){ + tableData.splice(0, tableData.length, ...data.params[0]); + } // console.log("鏇存柊鍚庢暟鎹�", data.params[0]); }; // 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁� onMounted(() => { + confirmBrowser();//鑾峰彇娴忚鍣� fetchFlowCardId(); fetchTableData(); // 鑾峰彇鏁版嵁 socket = initializeWebSocket(socketUrl, handleMessage); @@ -289,16 +304,69 @@ printLayer.value = row.layer dialogTableVisible.value = true; setTimeout(() => { - printFlowCard(); // 鏇挎崲鎴愪綘瑕佹墽琛岀殑鍑芥暟鍚� + printFlowCard(); dialogTableVisible.value = false; - }, 1000); - ; + }, 2000); +} +const open1 = async (row) => { +printFlowCardId.value = row.flowCardId; +printLayer.value = row.layer +dialogTableVisible1.value = true; +setTimeout(() => { + printFlowCard1(); + //dialogTableVisible1.value = false; +}, 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; + + // alert(/Chrome/.test(userAgent) && !/Edge/.test(userAgent)); + + // 鏍峰紡鎺у埗涓庢墦鍗版棤鍏崇殑鍏冪礌闅愯棌 + let style = doc.createElement("style"); + console.log("style1:"+style.innerHTML) + style.innerHTML = + "body>#" + + printId + + "{display:none;}@media print{" + + "@page {" + + " size: auto; " + + " margin: 10mm 5mm 10mm 5mm; " + + " }body>:not(#" + + printId + + "){display:none !important;}body>#" + + printId + + "{display:block;}#" + + printId + + "{display: block; padding: 0; margin: 0; width: 100%; position: absolute; top: 0; left: 0; height: 100vh; box-sizing: border-box;}} "; + + 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); +} + +const printFlowCard1 = () => { + // 闇�瑕佹墦鍗扮殑灞�閮ㄥ尯鍩熻祴浜�"print-wrap"鐨刬d + let el = document.getElementById("printFlowCard"); let doc = document; let body = doc.body || doc.getElementsByTagName("body")[0]; let printId = "print-" + Date.now(); @@ -315,7 +383,7 @@ "{display:none}@media print{" + "@page {" + " size: auto; " + - " margin: 2mm 2mm 0mm 1mm; " + + " margin: 2mm 2mm 2mm 2mm; " + " }body>:not(#" + printId + "){display:none !important}body>#" + @@ -337,6 +405,8 @@ } + + // beforeUnmount(() => { // closeWebSocket(); // }); @@ -344,15 +414,15 @@ </script> <template> <div> - <el-button style="margin-top: 5px;margin-left: 10px;" id="searchButton" type="primary" + <el-button style="margin-top: 10px;margin-left: 10px;margin-bottom: 10px;" id="searchButton" type="primary" @click="dialogFormVisibleaDownGlass = true">钀芥灦璇︽儏 </el-button> - <el-switch style="margin-top: 5px;margin-left: 10px;" v-model="autoPrint" class="mb-2" :inactive-text="$t('鑷姩鎵撳嵃')" + <el-switch style="margin-top: 10px;margin-left: 15px;margin-bottom: 10px;" v-model="autoPrint" class="mb-2" :inactive-text="$t('鑷姩鎵撳嵃')" @change="handleChange"/> <el-card style="flex: 1;" v-loading="loading"> <el-card style="flex: 1;margin-left: 4px;margin-top: 1px;" v-loading="loading"> <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;"> - <el-table height="200px" ref="table" @selection-change="handleSelectionChange" :data="tableData" + <el-table height="350px" ref="table" @selection-change="handleSelectionChange" :data="tableData" :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }"> <el-table-column prop="workstationId" align="center" :label="$t('reportWork.lowerbit')" min-width="80"/> <el-table-column prop="workstationId" align="center" :label="$t('reportWork.shelfnumber')" @@ -372,14 +442,15 @@ </el-tag> </template> </el-table-column> - <el-table-column fixed="right" :label="$t('reportWork.operate')" align="center" width="200"> + <el-table-column fixed="right" :label="$t('reportWork.operate')" align="center" width="400"> <template #default="scope"> <el-button size="mini" type="text" plain v-show="scope.row.enableState !== '宸插惎鐢�'" @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(scope.row)" :disabled="scope.row.flowCardId == null">鎵撳嵃</el-button> + <el-button @click="open(scope.row)" :disabled="scope.row.flowCardId == null">鎵撳嵃娴佺▼鍗�</el-button> + <el-button @click="open1(scope.row)" :disabled="scope.row.flowCardId == null">鎵撳嵃鏍囩</el-button> </template> </el-table-column> @@ -397,9 +468,6 @@ <el-option label="5" value="5"></el-option> <el-option label="6" value="6"></el-option> <el-option label="7" value="7"></el-option> - <el-option label="8" value="8"></el-option> - <el-option label="9" value="9"></el-option> - <el-option label="10" value="10"></el-option> </el-select> <el-select v-model="selectValuesa[1]" filterable :placeholder="$t('basicData.plselectproject')" clearable @@ -408,7 +476,7 @@ </el-select> <span class="demonstration">鏃堕棿娈�</span> - <el-date-picker v-model="timeRange" type="datetimerange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�" + <el-date-picker v-model="timeRange" type="datetimerange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�" value-format = "YYYY-MM-DD hh:mm:ss" end-placeholder="缁撴潫鏃ユ湡"> </el-date-picker> @@ -488,13 +556,14 @@ </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> --> + <el-dialog id="sizePrintCalrd" v-model="dialogTableVisible" destroy-on-close > <print-flow id="child" :printFlowCardId="printFlowCardId" :printLayer="printLayer" style="width: 100%;height: 100%"/> </el-dialog> + <el-dialog id="sizePrintCalrd1" v-model="dialogTableVisible1" destroy-on-close > + <print-label id="printFlowCard" :printFlowCardId="printFlowCardId" :printLayer="printLayer" + style=""/> + </el-dialog> </template> <style scoped> -- Gitblit v1.8.0