Administrator
2025-07-17 5837c5bfc1ee9a7251bd0218dedd33e00d55e546
src/main/resources/templates/febs/views/modules/clothesType/orderList.html
@@ -171,7 +171,7 @@
                    febs.alert.warn('请选择订单');
                    return;
                }
                printSelect(data)
                printSelectData(ids)
            }
            if (layEvent === 'deliverGoods') {
@@ -300,7 +300,7 @@
                    febs.alert.warn('请选择待发货的订单');
                    return;
                }
                window.location.href = ctx + "admin/order/exportOrderList?ids="+ids;
                window.location.href = ctx + "admin/clothesType/exportOrderList?ids="+ids;
            }
        });
@@ -310,46 +310,100 @@
         * [自定义打印选中行数据]
         * @param  {[type]}  allData [传入选中行]
         */
        function printSelect(allData) {
       function printSelectData(allData) {
           let orderId = allData;
           console.log(orderId);
            $.ajax({
                url: '/admin/clothesType/printOrder/'+orderId,
                type: "get",
                contentType: 'application/json',
                success(res) {
                    console.log(res);
                    printSelect(res.data);
                },
                error(xhr, status, error) {
                    console.error("AJAX 请求失败:", error);
                    alert("请求失败,请重试");
                }
            });
        }
        function printSelect(data) {
            //用于包含内容
            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>"
            console.log(data);
            var template =
                "<div class='main'>" +
                "<div style='text-align: center;font-size: 30px;font-weight: bold;margin-bottom: 10px'>订单编号:" + data.orderNo + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>类型:" + data.typeName + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>布料:" + data.clothName + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>编码:" + data.clothCode + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>尺码:" + data.sizeName + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>编码:" + data.sizeCode + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>工艺:" + data.artName + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>编码:" + data.artCode + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>正面图案:" + data.patternName + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>编码:" + data.patternCode + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>文案:" + data.patternText + "</div>" +
                "<div class='print-images' style='font-size: 30px;font-weight: bold;'>图片:" +
                    "<img style='width: 200px; height: 200px; max-width: 80%; margin-top: 5px;' src="+ data.patternImage+">" +
                "</div>" +
                contentHtml += template;
            }
                "<div style='font-size: 30px;font-weight: bold;'>反面图案:" + data.locationName + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>编码:" + data.locationCode + "</div>" +
                "<div style='font-size: 30px;font-weight: bold;'>文案:" + data.locationText + "</div>" +
                "<div class='print-images' style='font-size: 30px;font-weight: bold;'>图片:" +
                    "<img style='width: 200px; height: 200px; max-width: 80%; margin-top: 5px;' src="+ data.locationImage+">" +
                "</div>" +
                "<div class='print-images' style='font-size: 30px;font-weight: bold;'>正面:" +
                    "<img style='width: 200px; height: 200px; max-width: 80%; margin-top: 5px;' src="+ data.typeFront+">" +
                "</div>" +
                "<div class='print-images' style='font-size: 30px;font-weight: bold;'>反面:" +
                    "<img style='width: 200px; height: 200px; max-width: 80%; margin-top: 5px;' src="+ data.typeBack+">" +
                "</div>" +
                "</div>"
            //contentHtml为已拼凑好的内容
            $(v).append(contentHtml)
            v.innerHTML = template;
            //新建窗口
            var h = window.open("打印窗口", "_blank");
            //写入拼凑内容
            h.document.write(f + $(v).prop("outerHTML"));
            h.document.close();
            //在新窗口的 document 中查找图片
            ensureImagesLoaded(h.document, '.print-images img')
                .then(() => h.print())
                .catch(() => layer.msg('部分图片加载失败'));
            //调用打印
            h.print();
            //关闭页面
            h.close();
        }
        function ensureImagesLoaded(doc, selector) {
            var imgs = $(selector, doc); // 👈 在指定文档中查找
            var promises = [];
            imgs.each(function() {
                var img = this;
                var promise = new Promise(function(resolve, reject) {
                    if (img.complete && img.naturalWidth !== 0) {
                        resolve();
                    } else {
                        $(img).on('load', resolve).on('error', reject);
                    }
                });
                promises.push(promise);
            });
            return Promise.all(promises);
        }
        function refundOrder(id) {
            febs.get(ctx + 'admin/clothesType/refundOrder/' + id, null, function () {
                febs.alert.success('操作成功');