From 46d9a52288d5c36985435e775a8433df4e12000b Mon Sep 17 00:00:00 2001 From: Administrator <15274802129@163.com> Date: Wed, 16 Jul 2025 14:27:59 +0800 Subject: [PATCH] feat(mall): 添加自定义打印功能并优化订单相关接口 --- src/main/resources/templates/febs/views/modules/clothesType/orderList.html | 68 ++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) diff --git a/src/main/resources/templates/febs/views/modules/clothesType/orderList.html b/src/main/resources/templates/febs/views/modules/clothesType/orderList.html index d5a50f8..a498a93 100644 --- a/src/main/resources/templates/febs/views/modules/clothesType/orderList.html +++ b/src/main/resources/templates/febs/views/modules/clothesType/orderList.html @@ -100,6 +100,7 @@ </script> <script type="text/html" id="tableToolBarClothesOrder"> <div class="layui-btn-container"> + <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="printSelect">自定义打印</button> <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="deliverGoods">发货</button> <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="updateDeliver">修改物流信息</button> <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="refundOrder">仅退款</button> @@ -150,6 +151,28 @@ var layEvent = obj.event; var id = obj.config.id; var checkStatus = table.checkStatus(id); + if(layEvent === 'printSelect'){ + let data = checkStatus.data; + if (data.length > 1) { + febs.alert.warn('每次只能操作一个订单'); + return; + } + let ids = ""; + for(let i = 0;i < data.length;i++){ + console.log(data[i].status); + if(data[i].status != 2){ + febs.alert.warn('请选择待发货的订单'); + return; + }else{ + ids = data[i].id; + } + } + if(ids == null || ids == ""){ + febs.alert.warn('请选择订单'); + return; + } + printSelect(data) + } if (layEvent === 'deliverGoods') { let data = checkStatus.data; @@ -282,6 +305,51 @@ }); + + /* + * [自定义打印选中行数据] + * @param {[type]} allData [传入选中行] + */ + function printSelect(allData) { + //用于包含内容 + var v = document.createElement("div"); + //页面头部,导入css ,media="print"表示打印时使用该样式 + var f = ["<head>", "<style>", "div{font-size:8px;}", ".main{width:100%;}", + ".main div{width:100%;display:inline-block;}", "</style>", "</head>" + ].join(""); + var contentHtml = ""; + for (let i = 0; i < allData.length; i++) { + let data = allData[i] + var template = + "<div class='main'>" + + "<table cellspacing=\"0\" width=\"100%\" style=\"border-collapse: separate; border-spacing: 0px;\">" + + "<tr>" + + "<td style='width: 50%;'>" + + "<img src='" + data.img + "' style='width: 100%;'/>" + + "</td>" + + "<td style='width: 50%;'>" + + "<img src='" + data.img + "' style='width: 100%;'/>" + + "</td>" + + "</tr>" + + "</table>" + + "<div style='text-align: center;font-size: 10px;font-weight: bold;margin-bottom: 10px'>订单编号:" + data.orderNo + "</div>" + + "</div>" + + contentHtml += template; + } + + //contentHtml为已拼凑好的内容 + $(v).append(contentHtml) + //新建窗口 + var h = window.open("打印窗口", "_blank"); + //写入拼凑内容 + h.document.write(f + $(v).prop("outerHTML")); + //调用打印 + h.print(); + //关闭页面 + h.close(); + } + function refundOrder(id) { febs.get(ctx + 'admin/clothesType/refundOrder/' + id, null, function () { febs.alert.success('操作成功'); -- Gitblit v1.9.1