<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <%@include file="/views/common.jsp" %>
</head>

<style>
    #craft_draw .layui-form-select .layui-edge {
        right: 17%;
    }
</style>
<body>
<div class="big_box">
    <div class="left_div">
        <h1 class="h2">定制衫</h1> <span style="color:red;font-weight:700;"></span>
        <hr>
        <form class="layui-form">
            <input type="hidden" name="proTypeValue" class="layui-input" value="定制衫">
            <input type="hidden" id="proTypeValue" value="定制衫">
            <p>
                型号
            </p>
            <div class="layui-form-item">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="YP" title="YP 1902" lay-skin="primary" checked>
                <input type="radio" name="kindValue" lay-filter="kindValue" value="XW" title="XW 601#" lay-skin="primary">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="EP" title="EP 2803" lay-skin="primary">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="ZT" title="ZT 901#" lay-skin="primary">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="T恤" title="T恤" lay-skin="primary">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="马甲" title="马甲" lay-skin="primary">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="工程服" title="工程服" lay-skin="primary">
            </div>
            <p>
                材质
            </p>
            <div class="layui-form-item">
                <select name="kind1Value" id="kind1Value" lay-filter="kind1Value" class="select">
                    <option value="圆领速干">圆领速干</option>
                </select>
            </div>
            <div id="styles">
                <p>
                    款式
                </p>
                <div class="layui-form-item">
                    <input type="radio" name="styles" lay-filter="styles" value="成人款" title="成人款"
                           lay-skin="primary" checked>
                    <input type="radio" name="styles" lay-filter="styles" value="儿童款" title="儿童款"
                           lay-skin="primary">
                </div>
            </div>

            <p>
                尺码
            </p>
            <div class="layui-form-item">
                <select id="size" lay-filter="size" class="select">
                    <option value="S" selected>S</option>
                    <option value="M">M</option>
                    <option value="L">L</option>
                    <option value="XL">XL</option>
                    <option value="2XL">2XL</option>
                    <option value="3XL">3XL</option>
                    <option value="4XL">4XL</option>
                    <option value="5XL">5XL</option>
                </select>
            </div>
            <p>
                颜色
            </p>
            <div class="layui-form-item">
                <select id="color" lay-filter="color" class="select">
                    <option value="宝蓝" selected>宝蓝</option>
                    <option value="黑色">黑色</option>
                    <option value="白色">白色</option>
                    <option value="湖蓝">湖蓝</option>
                    <option value="银光绿">银光绿</option>
                    <option value="黄色">黄色</option>
                    <option value="橙色">橙色</option>
                    <option value="天蓝">天蓝</option>
                    <option value="红色">红色</option>
                </select>
            </div>
            <p>
                数量（件）
            </p>
            <div class="layui-form-item">
                <input type="text" placeholder="请输入整数" autocomplete="off" name="count" id="count" class="layui-input"
                       lay-verify="number">
            </div>
            <p>
                款数
            </p>
            <div class="layui-form-item">
                <input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1"
                       class="layui-input" lay-verify="number">
            </div>
            <div class="location">
                <p>
                    工艺<span style="font-size:14px;color:red">印花最大尺寸32*40CM</span>
                </p>
                <div class="layui-input-block location">
                    <input type="checkbox" name="craft" lay-filter="switch" value="烫画" title="烫画">
                    <span class="layui-inline" id="craft_draw" style="display: none;align-items: center">
                     <div class="layui-form-item" style="align-items: center;display: flex">
                        <span style="flex-shrink: 0">位置：</span>
                        <select name="po_number" class="select" lay-verify="po_number" lay-filter="po_number">
                            <option value="1">1</option>
                            <option value="2">2</option>
                        </select>
                    </div>
                    <div class="layui-form-item" style="align-items: center;display: flex">
                         <span>尺寸1：</span>
                        <select name="size" class="select">
                            <option value="10*10">10*10CM内</option>
                            <option value="15*15">15*15CM内</option>
                            <option value="15*20">15*20CM内</option>
                            <option value="25*15">25*15CM内</option>
                            <option value="20*20">20*20CM内</option>
                            <option value="25*25">25*25CM内</option>
                            <option value="30*30">30*30CM内</option>
                            <option value="30*40">30*40CM内</option>
                        </select>
                    </div>
                </span>
                    <input type="checkbox" name="craft" lay-filter="switch" value="丝印" title="丝印">
                    <span id="craft_print" style="display: none;align-items: center">
                    <div style="width: 150px;align-items: center;display: flex">
                    <span style="flex-shrink: 0">位置：</span>
                     <input type="text" placeholder="请输入整数" autocomplete="off" name="po_number" class="layui-input"
                            lay-verify="number" value="1" disabled></div>
                    <div style="width: 150px;align-items: center;display: flex">
                    <span style="flex-shrink: 0">颜色：</span>
                    <input type="text" placeholder="请输入整数" autocomplete="off" name="co_number" class="layui-input"
                           lay-verify="number" value="1" disabled></div>
                </span>
                </div>
            </div>
            <div class="specific" style="display: none">
                <p>
                    工艺<span style="font-size:14px;color:red">备注：丝印量小不建议做，多色不建议做，渐变色不建议做  </span>
                </p>
                <div class="layui-form-item specific">
                    <input type="checkbox" name="craft" lay-filter="switch" value="烫画" title="烫画">
                    <input type="checkbox" name="craft" lay-filter="switch" value="刺绣" title="刺绣">
                    <input type="checkbox" name="craft" lay-filter="switch" value="丝印" title="丝印">
                    <div class="layui-inline definite" style="display: none">
                        <input type="checkbox" name="craft" value="前胸" title="前胸" disabled>
                        <input type="checkbox" name="craft" value="后背" title="后背" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-input-block">
                <input type="checkbox" name="craft" lay-filter="ui_craft" value="抠图" title="抠图">
                <div class="layui-inline crop" style="display:none;width: 80px">
                    <input class="layui-input" type="text" name="cropNumber">
                </div>
            </div>
            <hr>
            <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="acount_btn">计算</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
            <h2>计算结果-
                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
                        onclick="copyResult()">点击复制
                </button>
            </h2>
            <div>
                <textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
                <%@include file="../acountExpressFee.jsp" %>
            </div>
            <div>
                <table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
            </div>
        </form>
    </div>
    <div class="right_div" style="margin-left:50px;">
        <div class="layui-carousel" id="test1">
            <div carousel-item id="carousel"></div>
            <br>
            <div id="remark" style="font-size:20px;color:red"></div>
        </div>
    </div>
</div>
</body>
<script src="../../js/carousel.js" charset="utf-8"></script>
<%@include file="/views/copyResult.jsp" %>
<script>
    layui.use(['table', 'form', 'carousel'], function () {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        var carousel = layui.carousel;
        var table = layui.table;

        //建造实例
        ins = carousel.render({});

        function getProductImage(craft) {

            $("#carousel").empty();
            $("#remark").empty();
            let data = {proTypeValue: "定制衫"}
            let remark = "";
            let html = "";
            let kindValue = $("input[name='kindValue']:checked").val();
            let styles = $("input[name='styles']:checked").val();
            let kind1Value = $("select[name='kind1Value'] option:selected").val();
            let className = "location";
            if (kindValue == "T恤" || kindValue == "马甲" || kindValue == "工程服") {
                className = "specific";
            }
            if (!!craft) {
                data.craftValue = "craft";
            } else {
                data.kindValue = kindValue;
                if (className == "location") {
                    data.kind2Value = styles;
                } else {
                    data.kind2Value = kind1Value
                }
            }
            $.ajax({
                url: "${pageContext.request.contextPath}/getImgs",
                type: "GET",
                data,
                //dataType : "json",
                success: function (result) {
                    for (let i = 0; i < result.length; i++) {
                        // 只留一个remark
                        remark = "";
                        html += '<div><img style="width:100%;height: 100%;object-fit: contain" src="' + result[i].imgUrl + '"></div>';
                        remark += '<div><span>' + result[0].remark + '<span/></div>';
                    }
                    $("#carousel").append(html);
                    // 如果没有说明，就不显示null
                    if (remark.indexOf("null") < 0) {
                        $("#remark").append(remark);
                    }
                    // 如果没有轮播图就隐藏
                    if (result.length == 0) {
                        document.getElementById("test1").style.display = "none";   //隐藏
                    } else {
                        document.getElementById("test1").style.display = "block";   //显示
                        ins.reload({
                            elem: '#test1',
                            width: result[0].imgWidth,  //设置容器宽度
                            height: result[0].imgHeight
                        });
                    }
                }
            });
        }

        form.on("select(po_number)", (data) => {
            let html = '';
            if (data.value > 1) {
                for (let i = 1; i < data.value; i++) {
                    html += `<div class="layui-form-item" style="align-items: center;display: flex">
                         <span>尺寸` + parseInt(i + 1) + `：</span>
                        <select name="size" class="select">
                            <option value="10*10">10*10CM内</option>
                            <option value="15*15">15*15CM内</option>
                            <option value="15*20">15*20CM内</option>
                            <option value="25*15">25*15CM内</option>
                            <option value="20*20">20*20CM内</option>
                            <option value="25*25">25*25CM内</option>
                            <option value="30*30">30*30CM内</option>
                            <option value="30*40">30*40CM内</option>
                        </select>
                    </div>`
                }
                $("#po_num_item").empty().append(html);
            }
            form.render();
        })
        form.on('select(kind1Value)', (data) => {
            let kindValue = $("input[name='kindValue']:checked").val();
            setHtml(kindValue, data.value);
            form.render();
            getProductImage()
        })
        form.on("radio(styles)", (data) => {
            let kindValue = $("input[name='kindValue']:checked").val();
            setHtml(kindValue, data.value)
            form.render();
            getProductImage()
        });
        form.on("radio(kindValue)", (data) => {
            $("#styles").show();
            $("input[name='styles'][value='成人款']").prop("checked", true);
            $("input[name='styles'][value='儿童款']").prop("disabled", false);

            if (data.value == "EP") {
                $("input[name='styles'][value='儿童款']").prop("disabled", true);
            }
            if (data.value == "ZT") {
                $("input[name='styles'][value='儿童款']").prop("disabled", true);
            }
            $(".location").show();
            $(".specific").hide();
            if (data.value == "T恤" || data.value == "马甲" || data.value == "工程服") {
                $("#styles").hide();
                $(".location").hide();
                $(".specific").show();
            }
            let kindValueHtml = '';
            if (data.value == "T恤") {
                kindValueHtml = `
                    <option value="1108T">T恤1108T</option>
                    <option value="2604">T恤2604</option>
                    <option value="8089">T恤8089</option>
                    <option value="1101">T恤1101</option>
                    <option value="1102">T恤1102</option>
                    <option value="9128">T恤9128</option>
                    <option value="9129">T恤9129</option>
                `;
                setHtml(data.value, '1108T')
            } else if (data.value == "马甲") {
                kindValueHtml = `
                    <option value="9022">马甲9022</option>
                    <option value="9020">马甲9020</option>
                    <option value="9008">马甲9008</option>
                    <option value="9023">马甲9023</option>
                    <option value="9002">马甲9002</option>
                `;
                setHtml(data.value, '9022')
            } else if (data.value == "工程服") {
                kindValueHtml = `
                    <option value="6010A">工装6010A</option>
                    <option value="6016">工装6016</option>
                    <option value="5608XM">工装5608XM</option>
                    <option value="5608K">工装5608K</option>
                    <option value="903">工装903</option>
                    <option value="901">工装901</option>
                `;
                setHtml(data.value, '6010A')
            } else {
                setHtml(data.value, '成人款')
            }
            if (kindValueHtml != '') {
                $("#kind1Value").empty().append(kindValueHtml);
            }
            form.render();
            getProductImage()
        })

        // 配置映射：key 为 '${kind}_${styles}'，value 包含对应要更新的内容
        const PRODUCT_CONFIG = {
            // XW 成人款
            XW_成人款: {
                kind1Value: '圆领棉质',
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['砖红', '墨绿色', '白色', '紫色', '雾霾蓝', '克莱因蓝', '米杏', '姜黄', '玫红', '豆绿', '酒红', '卡其色', '天蓝色', '铁灰', '红色', '黑色', '浅灰色', '绿色']
            },
            // XW 儿童款
            XW_儿童款: {
                size: ['100', '110', '120', '130', '140', '150'],
                color: ['黑色', '白色', '粉色', '大红色']
            },
            // YP 成人款
            YP_成人款: {
                kind1Value: '圆领速干',
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['宝蓝', '黑色', '白色', '湖蓝', '银光绿', '黄色', '橙色', '天蓝', '红色']
            },
            // YP 儿童款
            YP_儿童款: {
                size: ['100', '110', '120', '130', '140', '150'],
                color: ['砖红', '墨绿色', '白色', '紫色', '雾霾蓝', '克莱因蓝', '米杏', '姜黄', '玫红', '豆绿', '酒红', '卡其色', '天蓝色', '铁灰', '红色', '黑色', '浅灰色', '绿色']
            },
            // EP 成人款
            EP_成人款: {
                kind1Value: 'polo速干',
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['孔蓝色', '灰色', '天蓝色', '彩蓝色', '白色', '草绿色', '藏青色', '橙色', '黑色', '红色', '黄色']
            },
            // ZT 成人款（无 5XL，颜色列表不同）
            ZT_成人款: {
                kind1Value: 'popl棉质',
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL'],
                color: ['黑色', '白色', '橘色', '天蓝色', '果绿色', '孔蓝色', '红色', '藏青色', '玫红色', '紫色', '黄色', '草绿色']
            },
            // EP 儿童款 和 ZT 儿童款 无配置，不会产生任何更新
            T恤_1108T: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['石耀黑', '钢铁灰拼石耀黑', '石耀黑拼钢铁灰', '丈青拼钢铁灰', '钢铁灰', '丈青色']
            },
            T恤_2604: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL', '6XL'],
                color: ['黑色', '乌金蓝', '蔚来灰', '深空灰', '白色', '冰川蓝', '幽暗绿', '木槿紫', '爱马仕橙', '石榴红']
            },
            T恤_8089: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL', '6XL'],
                color: ['藏蓝色', '灰咖绿', '雾霾蓝', '银灰色', '黑色', '白色', '咖色', '中灰色']
            },
            T恤_1101: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['浅灰拼红', '藏蓝拼浅灰', '浅灰拼藏蓝', '黑色拼红', '黑色拼深灰', '藏蓝拼红', '纯白色', '纯黑色', '纯藏蓝色']
            },
            T恤_1102: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['藏蓝拼橘', '藏蓝拼红', '藏蓝拼浅灰', '浅灰拼藏蓝', '黑色拼深灰']
            },
            T恤_9128: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL', '6XL'],
                color: ['白色', '藏青色', '黑色', '深灰色', '苹果蓝', '丁香紫', '蔚来灰', '浅蓝', '粉红色']
            },
            T恤_9129: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['藏青色', '黑色', '深灰色', '浅蓝', '丁香紫', '粉红色', '蔚来灰']
            },
            马甲_9022: {
                size: ['L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['黑色', '红色', '藏蓝色']
            },
            马甲_9020: {
                size: ['L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['黑色', '红色', '藏蓝色', '灰色']
            },
            马甲_9008: {
                size: ['L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['黑色', '灰色', '橘色', '宝蓝色', '黄色', '红色', '背面']
            },
            马甲_9023: {
                size: ['L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['理想绿', '清华紫', '黑色', '藏蓝色', '红色', '熊来灰']
            },
            马甲_9002: {
                size: ['L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['黑色拼黄', '绿色拼黄', '藏蓝拼红', '宝蓝拼黄', '黄色拼黑', '灰色拼宝蓝', '红色拼黑']
            },
            工程服_6010A: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['藏蓝色', '灰色', '宝蓝色']
            },
            工程服_6016: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['橘红色']
            },
            工程服_5608XM: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL'],
                color: ['黑色拼灰', '藏蓝拼灰', '浅灰色', '藏蓝', '黑色', '雾霾蓝']
            },
            工程服_5608K: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['黑色']
            },
            工程服_903: {
                size: ['S', 'M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
                color: ['黑色']
            },
            工程服_901: {
                size: ['160cm', '165cm', '170cm', '175cm', '180cm', '185cm', '190cm', '195cm'],
                color: ['藏蓝色', '宝蓝色', '灰色']
            },
        };

        function setHtml(kind, styles) {
            const key = kind + "_" + styles;
            const config = PRODUCT_CONFIG[key];
            $("#craft_print").css("display", "none");
            $("#craft_draw").css("display", "none");
            $("input[name='craft']").prop("checked", false);
            if (!config) return;  // 没有配置则不做任何操作

            // 更新 kind1Value（仅当配置中存在时）
            if (config.kind1Value !== undefined) {
                $("#kind1Value").empty().append('<option value="' + config.kind1Value + '">' + config.kind1Value + '</option>');
            }

            // 更新 size 下拉框（第一个选项默认选中）
            if (config.size) {
                const sizeHtml = config.size.map((size, idx) => {
                    return '<option value="' + size + '"  > ' + size + ' </option>'
                }).join('');
                $("#size").empty().append(sizeHtml);
            }

            // 更新 color 下拉框（第一个选项默认选中）
            if (config.color) {
                const colorHtml = config.color.map((color, idx) => {
                    return '<option value="' + color + '" > ' + color + ' </option>'
                }).join('');
                $("#color").empty().append(colorHtml);
            }
        }

        let craft_list1 = ["烫画", "丝印", "刺绣"];
        form.on("checkbox(switch)", (data) => {
            let craft_list = [];
            $("input[name='craft']:checked").each(function () {
                if (!$(this).is(':disabled')) {
                    craft_list.push($(this).val());
                }
            });
            const carft1 = craft_list1.filter(craft => craft_list.includes(craft));
            if (carft1.length > 1) {
                $(data.elem).next().attr("class", "layui-unselect layui-form-checkbox");
                $(data.elem).prop("checked", false);
                layer.msg(craft_list1.join("-") + '不能同时选择！', {offset: ['300px', '300px']}, function () {
                });
                return false;
            }
            let className = $(data.elem).parent().hasClass("location") ? "location" : "specific";

            if (data.value == '烫画' && className == "location") {
                if (data.elem.checked) {
                    $("#craft_draw").css("display", "flex");
                    $("#craft_draw input").prop("disabled", false);
                    $("#craft_draw select").prop("disabled", false);
                } else {
                    $("#craft_draw").css("display", "none");

                    $("#craft_draw input").prop("disabled", true);
                    $("#craft_draw select").prop("disabled", true);
                }
            }
            if (data.value == '丝印' && className == "location") {
                if (data.elem.checked) {
                    $("#craft_print").css("display", "flex");
                    $("#craft_print input").prop("disabled", false);
                } else {
                    $("#craft_print").css("display", "none");
                    $("#craft_print input").prop("disabled", true);
                }
            }
            if (className == "specific") {
                if (data.elem.checked) {
                    $(".definite").show()
                    $(".definite input").prop("disabled", false);
                } else {
                    $(".definite").hide();
                    $(".definite input").prop("disabled", true);
                }
            }
            getProductImage(data.elem.checked ? data.value : "")
            form.render();
        })
        form.on('checkbox(ui_craft)', function (data) {
            let craft_list = [];
            let kindValue = $('input[name="kindValue"]:checked').val();
            craft_list.push($("select[name='craft'] option:selected").val());
            $("input[name='craft']:checked").each(function () {
                if (!$(this).is(':disabled')) {
                    craft_list.push($(this).val());
                }
            });

            if (data.value == '抠图') {
                $(".crop").hide();
                $(".crop").find("input").prop("disabled", true)
                if (data.elem.checked) {
                    $(".crop").show();
                    $(".crop").find("input").prop("disabled", false)
                }
            }
            form.render();
        })
        // 点击计算，计算价格
        form.on('submit(acount_btn)', function (data) {

            let size = $("select[name='size'] option:selected").val();
            let kind = $("input[name='kindValue']:checked").val();
            let count = $("#count").val();
            let craft = $("input[name='craft']:checked").val();
            let className = "location";
            if (kind == "T恤" || kind == "马甲" || kind == "工程服") {
                className = "specific";
            }

            let arr = [];
            $("input[name='craft']:checked").each(function () {
                if (!$(this).is("disabled")) {
                    if ($(this).val() == "抠图") {
                        arr.push($(this).val() + $("input[name='cropNumber']").val());
                        return;
                    }
                    arr.push($(this).val())
                }
            })
            if (!craft) {
                layer.msg('工艺必须选择！', {offset: ['300px', '300px']}, function () {
                });
                return false;
            }
            if (!count) {
                layer.msg('请输入数量！', {offset: ['300px', '300px']}, function () {
                });
                return false;
            }
            if (craft?.indexOf("烫画") > -1 && className == "location") {
                let t_po_number = $("#craft_draw select[name='po_number'] option:selected").val();
                if (!size) {
                    layer.msg('请输入尺寸！', {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
                if (!t_po_number) {
                    layer.msg('请输入位置数量！', {offset: ['300px', '300px']}, function () {
                    });
                    return false;

                }
            }
            if (className == "specific" && arr.length > 0) {
                if (!arr.includes("前胸") && !arr.includes("后背")) {
                    layer.msg('请选择位置！', {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
            }
            $.ajax({
                url: "${path}/getThanSum",
                type: "GET",
                data: $(".big_box form").serialize(),
                success: function (result) {
                    if (result.code == 100) {
                        layer.msg(result.msg, {offset: ['300px', '300px']}, function () {
                        });
                        return false;
                    }
                    let kind_value = {
                        "YP": "YP 1902",
                        "XW": "XW 601#",
                        "EP": "EP 2803",
                        "ZT": "ZT 901#",
                    }
                    let data = result.data.proList;

                    let styles = $("input[name='styles']:checked").val();
                    let po_number = $("input[name='po_number']").val();
                    let co_number = $("input[name='co_number']").val();
                    let kind1Value = $("select[name='kind1Value'] option:selected")[0].innerHTML;
                    let cSize = $("#size").val();
                    let cColor = $("#color").val();
                    let number = $("#number").val();
                    if (craft?.indexOf("烫画") > -1 && className == "location") {
                        po_number = $("select[name='po_number'] option:selected").val();
                    }
                    if (craft?.indexOf("丝印") > -1 && className == "location") {
                        po_number = $("input[name='po_number']").val();
                    }
                    let kind_text = "";
                    if (kind == "T恤" || kind == "马甲" || kind == "工程服") {
                        kind_text = kind
                    } else {
                        kind_text = kind_value[kind] + styles
                    }

                    let span_result = kind_text + '-' + kind1Value + '-' + cSize + '-' + cColor + '-(同款内容)\n工艺 :' + arr.join(",") + '\n'
                    if (craft?.indexOf("烫画") > -1 && className == "location") {
                        span_result += "烫画规格:" + size + "CM" + ",位置：" + po_number + "\n"
                    }
                    if (craft?.indexOf("丝印") > -1 && className == "location") {
                        span_result += "位置：" + po_number + "，" + "颜色：" + co_number + "\n"
                    }
                    if (number > 1) {
                        for (let i = 0; i < data.length; i++) {
                            span_result += number + '款 各' + data[i].count + "件，共" + data[i].price + "元" + '\n'
                            data[i].number = number;
                        }
                    } else {
                        for (let i = 0; i < data.length; i++) {
                            span_result += number + '款 ' + data[i].count + "件，共" + data[i].price + "元" + '\n'
                            data[i].number = number;
                        }
                    }
                    span_result += '包邮，免费设计呢~（偏远地区需补邮费）'
                        if(window.parent.system_isGai){
                            span_result +="\n\n亲 现在下单可以参加淘宝活动8.5折折扣哦!"
                        }
                    addLog(span_result);
                    $("#span_result").val(span_result);

                    getRemark($("#proTypeValue").val(), size, count, kind, number, arr, "");
                    //计算完自动复制文本
                    var e = document.getElementById("span_result");//对象是content
                    if (e.value != "") {
                        e.select();//选择对象
                        document.execCommand("Copy");//执行浏览器复制命令
                    }

                    //生成表格
                    table.render({
                        elem: '#priceTable',
                        even: true, //隔行变色
                        data: data, // 赋值已知数据
                        width: 500,
                        cols: [[
                            {
                                field: 'number',
                                width: '12%',
                                align: "center",
                                title: '款数'
                            }, {
                                field: 'count',
                                width: '16%',
                                align: "center",
                                title: '数量'
                            }, {
                                field: 'price',
                                width: '16%',
                                align: "center",
                                title: '报价'
                            }, {
                                field: 'weight',
                                width: '21%',
                                align: "center",
                                title: '重量（kg）'
                            }
                        ]],
                        done: function () {
                        }
                    });
                }
            });
            return false;
        });
    });

</script>
</html>