diff --git a/src/main/resources/static/img/broadcast/download.png b/src/main/resources/static/img/broadcast/download.png new file mode 100644 index 0000000..21918cb Binary files /dev/null and b/src/main/resources/static/img/broadcast/download.png differ diff --git a/src/main/resources/static/js/tools/toolsMge.js b/src/main/resources/static/js/tools/toolsMge.js index 5f3d667..cf09a62 100644 --- a/src/main/resources/static/js/tools/toolsMge.js +++ b/src/main/resources/static/js/tools/toolsMge.js @@ -1,6 +1,9 @@ let form, layer, table, tableIns; let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 let orgData,selectOrgId; +var modal = $('#myModal'); +var span = $('.close'); +var printButton = $('#PrintButton'); layui.use(['form', 'layer', 'table', 'laydate'], function () { form = layui.form; @@ -102,7 +105,7 @@ function initTable(dataList, limit, page) { }, { field: "qrCode", title: "二维码", width: '6%', unresize: true, align: "center", templet: function (d) { - return '打印'; + return '打印'; } }, // {title: "操作", unresize: true, width: 85, align: "center", @@ -146,29 +149,52 @@ function handleClick1(submitLocation,sampleTools,devModule,devCode,experTime,nex openIframe2("addOrEditUser", title, "child/certificateView.html", '30%', '70%', param); } -function handleClick2(view1) { - alert('Clicked on: ' + view1); +/** + * 打印二维码 + */ +function handleClick2(submitLocation,sampleTools,devModule,devCode,experTime,nextExperTime,experUser,experConclu,customName) { // 准备二维码内容 const qrCodeData = { - "样品名称": "安全帽", - "规格型号": "普通款", - "样品编号": "0001", - "检验日期": "2024-07-21", - "下次检验日期": "2024-09-30", - "试验人员": "admin", - "试验结果": "试验结论", - "送检单位": "单位" + "样品名称": sampleTools, + "规格型号": devModule, + "样品编号": devCode, + "检验日期": experTime, + "下次检验日期": nextExperTime, + "试验人员": experUser, + "试验结果": experConclu, + "送检单位": customName }; // 将对象转换为字符串 - const qrCodeString = JSON.stringify(qrCodeData, null, 2); // 使 JSON 字符串更易读 + const qrCodeString = JSON.stringify(qrCodeData, null, 2); // 清空二维码容器 $('#Qrcode').empty(); // 生成二维码 $('#Qrcode').qrcode(utf16to8(qrCodeString)); - // 打印二维码 - printQRCode(); + // 显示模态对话框 + modal.show(); + // // 打印二维码 + // printQRCode(); + window.print(); } +// 关闭模态对话框 +span.click(function() { + modal.hide(); +}); + +// 点击模态对话框外部区域也可以关闭模态对话框 +$(window).click(function(event) { + if ($(event.target).is(modal)) { + modal.hide(); + } +}); + +// 打印二维码 +printButton.click(function() { + // 使用浏览器的打印功能打印二维码 + window.print(); +}); + function utf16to8(str) { var out, i, len, c; out = ""; @@ -189,11 +215,6 @@ function utf16to8(str) { return out; } -function printQRCode() { - // 使用浏览器的打印功能打印页面 - window.print(); -} - // 获取参数 function getReqParams(page, limit, type) { var selectedValue =$('#sampleTools').val() diff --git a/src/main/resources/static/pages/tools/toolsMge.html b/src/main/resources/static/pages/tools/toolsMge.html index 391a2f7..f2a543b 100644 --- a/src/main/resources/static/pages/tools/toolsMge.html +++ b/src/main/resources/static/pages/tools/toolsMge.html @@ -40,12 +40,7 @@