From d6ed1287fa23fa25eacf57c0d83d533cb2f2bc45 Mon Sep 17 00:00:00 2001 From: feige <feige@qq.com> Date: 星期日, 10 九月 2023 10:04:34 +0800 Subject: [PATCH] 修改了家庭设备详情,增加了打印 --- ruoyi-ui/package.json | 1 + ruoyi-ui/src/views/device/equipmentInfo.vue | 31 +++++++++++++++++++++++++++++-- ruoyi-ui/src/main.js | 3 ++- ruoyi-ui/src/views/homeRoot/index.vue | 6 ++++-- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index a310ee3..4dbcb7d 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -59,6 +59,7 @@ "vue-count-to": "1.0.13", "vue-cropper": "0.5.5", "vue-meta": "2.4.0", + "vue-print-nb": "^1.7.5", "vue-router": "3.4.9", "vuedraggable": "2.24.3", "vuex": "3.6.0" diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js index 81e4afb..d2b9b00 100644 --- a/ruoyi-ui/src/main.js +++ b/ruoyi-ui/src/main.js @@ -81,7 +81,8 @@ Vue.config.productionTip = false const Base64 = require('js-base64').Base64 - +import Print from 'vue-print-nb' +Vue.use(Print) new Vue({ el: '#app', router, diff --git a/ruoyi-ui/src/views/device/equipmentInfo.vue b/ruoyi-ui/src/views/device/equipmentInfo.vue index 0d20627..44850ff 100644 --- a/ruoyi-ui/src/views/device/equipmentInfo.vue +++ b/ruoyi-ui/src/views/device/equipmentInfo.vue @@ -1,13 +1,18 @@ <template> - <div class="app-container"> + <div class="app-container" id="printable-content"> <div class="form-header mt"> <h1 style="font-size:21px;padding-top:30px;display: flex;justify-content: space-between;align-items: center;"> <span>瀹跺涵璁惧璇︽儏</span> <div style="display: flex; align-items: center;"> - <el-button size="mini" type="text" @click="checkNote()" v-hasPermi="['person:information:memo']"> + <el-button size="mini" type="text" v-print="'#printable-content'" v-hasPermi="['person:information:memo']"> <div class="form" ><el-icon style="padding-right:110px;"></el-icon> <span class="text" style="width: 69px;height: 26px;font-size: 16px; font-family: Microsoft YaHei-Regular, Microsoft YaHei; color: #EBA4AA;">澶囧繕鏈�</span></div> + </el-button> + <el-button size="mini" type="text" @click="print()" v-hasPermi="['person:information:memo']"> + <div class="form" ><el-icon style="padding-right:110px;"></el-icon> + <span class="text" style="width: 69px;height: 26px;font-size: 16px; + font-family: Microsoft YaHei-Regular, Microsoft YaHei; color: #EBA4AA;">鎵撳嵃</span></div> </el-button> </div> </h1> @@ -388,6 +393,28 @@ this.dsb = false this.btn = true }, + //鎵撳嵃 + print() + { + + setTimeout(() => { + // 鑾峰彇寰呮墦鍗扮殑鍐呭 + let printableContent = document.getElementById('printable-content').innerHTML; + console.log(printableContent) + // 鍒涘缓涓�涓柊鐨勭獥鍙e苟鍔犺浇鎵撳嵃鍐呭 + let printWindow = window.open('', '_blank'); + printWindow.document.write('<html><head><title>鎵撳嵃鍐呭</title></head><body>' + printableContent + '</body></html>'); + + // 鎵ц鎵撳嵃鎿嶄綔 + printWindow.document.close(); + + // 濡傛灉鍐呭涓湁鍥剧墖鎴栧叾浠栭渶瑕佷竴瀹氭椂闂村姞杞界殑锛岃浣跨敤娉ㄩ噴涓殑寤舵椂鎵撳嵃 + + printWindow.print() + }, 1000) + // printWindow.print(); + + }, //鏌ョ湅澶囧繕鏈� checkNote(row){ diff --git a/ruoyi-ui/src/views/homeRoot/index.vue b/ruoyi-ui/src/views/homeRoot/index.vue index 389666a..3bc2994 100644 --- a/ruoyi-ui/src/views/homeRoot/index.vue +++ b/ruoyi-ui/src/views/homeRoot/index.vue @@ -385,15 +385,17 @@ //鍐欑3浠g殑浠g爜閫昏緫锛岀敤涓や釜for寰幆鍐欑3浠� this.getGenByNum(this.rootThiList, this.rootList[0], 1, 3) console.log(this.rootThiList) - // console.log('-=-------') + console.log('-=-------') this.isShow_2=true this.isShow_3=true this.isShow_4=false }, generation_4(){ this.getList(4); - this.getGenByNum(this.rootFouList, this.rootList[0], 1, 3) + // alert(32) + this.getGenByNum(this.rootFouList, this.rootList[0], 1, 4) console.log(this.rootFouList) + // console.log('-=23-------') this.isShow_2=true this.isShow_3=true this.isShow_4=true -- Gitblit v1.9.1