From f99cf28040d6f3ca24073625c3cca2bfceaebd02 Mon Sep 17 00:00:00 2001 From: Yangwl <1726150332@qq.com> Date: Fri, 2 Aug 2024 15:36:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E5=93=81=E5=A4=87=E4=BB=B6=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/device/sparePartsLedger/index.vue | 114 +++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) diff --git a/src/views/device/sparePartsLedger/index.vue b/src/views/device/sparePartsLedger/index.vue index 5c6cdf78..5c447f59 100644 --- a/src/views/device/sparePartsLedger/index.vue +++ b/src/views/device/sparePartsLedger/index.vue @@ -135,6 +135,22 @@ > + + +
+ + + 打印 + +
+
+ +
+ +
    +
  • {{printData.materialCode}}
  • +
  • {{printData.materialDesc}}
  • +
+
+ +
+ + @@ -729,6 +759,7 @@ import { updateSparePartsLedger, } from "@/api/device/sparePartsLedger"; import { getToken } from "@/utils/auth"; +import QRCode from 'qrcode'; export default { name: "SparePartsLedger", @@ -753,7 +784,7 @@ export default { url: process.env.VUE_APP_BASE_API + "/device/sparePartsLedger/importFile", }, - + selectedRow: null, // 遮罩层 loading: true, // 选中数组 @@ -770,8 +801,25 @@ export default { sparePartsLedgerList: [], // 弹出层标题 title: "", + //打印弹出层标题 + printTitle:"", // 是否显示弹出层 open: false, + //是否显示打印弹出层 + printOpen: false, + // 打印 + printData: { + printable: 'printFrom', + ignore: ['no-print'], + workCenter: "暂无数据", + SAPNo: null, + manufacture: null, + auditor: null, + printDate: null, + factory: null, + productDate: null, + workTable: [], + }, // 查询参数 queryParams: { pageNum: 1, @@ -853,6 +901,7 @@ export default { }, }; }, + created() { this.getList(); }, @@ -1012,6 +1061,43 @@ export default { ); }, + + showPrint(row) { + + const storageId = row.storageId || this.ids; + getSparePartsLedger(storageId).then((response) => { + this.reset(); + this.printData = response.data; + this.printOpen = true; + // 使用 Vue 的 nextTick 来确保 DOM 已经更新 + this.$nextTick(() => { + const canvas = this.$refs.qrCanvas; + const options = { + width: 200, // 设定二维码的宽度 + height: 200 // 设定二维码的高度 + }; + QRCode.toCanvas(canvas,response.data.materialCode, options, error => { + if (error) console.error(error); + }); + }); + }); + }, + // 打印 + handlePrint(params) { + console.log(params) + printJS({ + printable: params.printable || 'printFrom', // 标签元素id + type: params.type || 'html', + maxWidth: 1500, // 最大宽度 + font_size: "",// 设置字体大小 + header: params.header, // '表单', + targetStyles: ['*'], + style: '@page {margin:0 10mm};', // 可选-打印时去掉眉页眉尾 + ignoreElements: params.ignore || [], // ['no-print'] + properties: params.properties || null + }) + }, + // 导入-导入窗口打开 handleImport() { this.upload.title = "设备信息导入"; @@ -1055,3 +1141,29 @@ export default { }, }; + +