<%@ 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>
    .layui-form-checkbox[lay-skin=primary] i {
        border-radius: 50px;
        width: 18px;
        height: 18px;
        line-height: 18px;
        margin-top: 3px;
    }

    .layui-form-checkbox[lay-skin=primary] span {
        color: black;
        margin-top: 3px;
        font-size: 14px;
    }

    #color_type .layui-form-select .layui-edge {
        right: 20px;
    }

    #leishe_type .layui-form-select .layui-edge {
        right: 20px;
    }

    #huangjin_type .layui-form-select .layui-edge {
        right: 20px;
    }
</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" id="proTypeValue" class="layui-input" value="杯垫">
            <p>材质</p>
            <div>
                <!--<input type="radio" name="kindValue" lay-filter="kindValue" value="3" title="350克铜版纸" checked>-->
                <input type="radio" name="kindValue" lay-filter="kindValue" value="6" title="600克铜版纸" checked>
                <input type="radio" name="kindValue" lay-filter="kindValue" value="4" title="900克双胶纸">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="10" title="轻羽（1.5mm厚度）">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="11" title="简单（1.0mm厚度)">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="12" title="透明PVC">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="13" title="香薰卡">
            </div>
            <div class="tagOther">
                <div class="layui-form-item pvcCraft" style="display: none">
                    <p>
                        规格
                    </p>
                    <div class="layui-form-item ">
                        <select name="size1" class="select" disabled>
                            <option value="2mm">2mm</option>
                            <option value="3mm">3mm</option>
                            <option value="5mm">5mm</option>
                        </select>
                    </div>
                </div>
                <p>
                    尺寸(CM/厘米) <span style="font-size: 14px; color: red">输入格式: 长 * 宽</span>
                </p>
                <div class="layui-form-item">
                    <input type="text" name="size" placeholder="格式:长*宽" id="size" class="layui-input"
                           autocomplete="off">
                </div>
                <p>
                    数量(张)
                </p>
                <div class="layui-form-item diycount">
                    <select name="count" class="select">
                        <option value="500">500</option>
                        <option value="1000">1000</option>
                        <option value="2000">2000</option>
                        <option value="5000">5000</option>
                        <option value="10000">10000</option>
                    </select>
                </div>
                <div class="layui-form-item fixcount" style="display: none">
                    <select name="count" class="select" disabled>
                        <option value="50">50</option>
                        <option value="100">100</option>
                        <option value="200">200</option>
                        <option value="500">500</option>
                        <option value="1000">1000</option>
                    </select>
                </div>
                <div class="layui-form-item pvcCraft" style="display: none">
                    <input type="text" name="count" placeholder="请输入整数" class="layui-input" autocomplete="off" disabled>
                </div>
                <div class="layui-form-item aromatherCraft" style="display: none">
                    <input type="text" name="count" placeholder="请输入整数" class="layui-input" autocomplete="off" disabled>
                </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="layui-form-item aromatherCraft" style="display: none">
                    <p>
                        规格
                    </p>
                    <div class="layui-form-item">
                        <select name="kind" class="select" lay-search>
                            <option value="1">300克</option>
                            <option value="2">600克</option>
                            <option value="3">1000克</option>
                        </select>
                    </div>
                    <p>
                        香味
                    </p>
                    <div class="layui-form-item" id="xiangwei">
                        <select name="craft" class="select">
                            <option value="桂花">桂花</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>
                            <option value="迪奥真我">迪奥真我</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>
                            <option value="蓝风铃">蓝风铃</option>
                            <option value="小苍兰">小苍兰</option>
                            <option value="柠檬香">柠檬香</option>
                            <option value="茉莉">茉莉</option>
                            <option value="邂逅">邂逅</option>
                            <option value="无味">无味</option>
                        </select>
                    </div>
                </div>
                <p>
                    客户旺旺
                </p>
                <div class="layui-form-item">
                    <input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
                           class="layui-input">
                </div>
                <div class="layui-form-item diycount" id="diycount">
                    <p>
                        工艺
                    </p>
                    <div class="layui-input-block">
                        <div class="layui-input-block">
                            <span style="float:left;margin-top:10px">裁切 ： </span>
                            <input type="radio" name="craftQie" lay-filter="craftQie" value="异形模切" title="异形模切" checked>

                        </div>
                        <div class="layui-input-block">
                            <span style="float:left;margin-top:10px">覆膜 ： </span>
                            <span style="display: none">
                                <input type="radio" id="non" name="craftMo" lay-filter="craftMo" la value="不覆膜"
                                       title="不覆膜"/>
                            </span>
                            <span>
                                <input type="radio" id="double" name="craftMo" lay-filter="craftMo" la value="双面覆哑膜"
                                       title="双面覆哑膜" checked/>
                            </span>
                        </div>
                        <div class="layui-input-block">
                            <span style="float:left;margin-top:10px">特殊工艺 ： </span>
                            <input type="radio" name="kind2Value" lay-filter="kind2Value" value="无" title="无" checked>
                            <span id="leishe_layout">
                                <input type="radio" name="kind2Value" lay-filter="kind2Value" value="烫镭射银" title="烫镭射银">
                                <span id="leishe_type" class="layui-inline" style="display: none;width: 150px">
                                    <select name="craft" class="select" disabled>
                                        <option value="单面烫镭射银" selected>单面烫镭射银</option>
                                        <option value="双面烫镭射银">双面烫镭射银</option>
                                    </select>
                                </span>
                            </span>
                            <input type="radio" name="kind2Value" lay-filter="kind2Value" value="烫黄金" title="烫黄金">
                            <span id="huangjin_type" class="layui-inline" style="display: none;width: 150px">
                                <select name="craft" class="select" disabled>
                                    <option value="单面烫黄金" selected>单面烫黄金</option>
                                    <option value="双面烫黄金">双面烫黄金</option>
                                </select>
                            </span>
                            <input type="radio" name="kind2Value" lay-filter="kind2Value" value="击凸" title="击凸">
                            <input type="radio" name="kind2Value" lay-filter="kind2Value" value="压凹" title="压凹">
                            <input type="radio" name="kind2Value" lay-filter="kind2Value" value="单面烫金+压凹"
                                   title="单面烫金+压凹">
                            <input type="radio" name="kind2Value" lay-filter="kind2Value" value="单面烫金+击凸"
                                   title="单面烫金+击凸">
                            <span id="color_type" class="layui-inline" style="display: none;width: 100px">
                                <select name="craft" class="select" disabled>
                                    <option value="无色" selected>无色</option>
                                    <option value="有色">有色</option>
                                    <option value="有色加凹凸">有色加激凸/有色加压凹</option>
                                </select>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item fixcount" id="fixcount" style="display: none">
                    <p>
                        工艺
                    </p>
                    <div class="layui-input-block">
                        <span style="float:left;margin-top:10px">形状 ： </span>
                        <input type="radio" name="aotu" value="圆形" title="圆形" checked>
                        <input type="radio" name="aotu" value="方形" title="方形">
                    </div>
                    <div class="layui-input-block">
                        <span style="float:left;margin-top:10px">无色压凹 ： </span>
                        <input type="radio" name="craft" id="yaao" lay-filter="switch" value="无色压凹" title="无色压凹"
                               checked>
                    </div>
                    <div class="layui-input-block">
                        <span style="float:left;margin-top:10px">击凸 ： </span>
                        <input type="radio" name="craft" lay-filter="switch" value="击凸" title="击凸">
                        <div style="display: none" id="jtcolor">
                            <input type="checkbox" name="jtcolor" lay-filter="color" value="金色" title="金色" checked>
                            <input type="checkbox" name="jtcolor" lay-filter="color" value="黑色" title="黑色">
                            <input type="checkbox" name="jtcolor" lay-filter="color" value="洋红色" title="洋红色">
                        </div>
                    </div>
                    <div class="layui-input-block">
                        <span style="float:left;margin-top:10px">烫金 ： </span>
                        <input type="radio" name="craft" lay-filter="switch" value="烫金" title="烫金">
                        <input type="radio" name="craft" lay-filter="switch" value="烫镭射银" title="烫镭射银">
                        <div style="display: none" id="tangcolor">
                            <input type="radio" name="tcolor" value="黑色" title="黑色" checked>
                            <input type="radio" name="tcolor" value="金色" title="金色">
                            <input type="radio" name="tcolor" value="红色" title="红色">
                        </div>
                        <div style="display: none" id="tangtype">
                            <input type="radio" name="tcolor" value="单面烫镭射银" title="单面烫镭射银" checked>
                            <input type="radio" name="tcolor" value="双面烫镭射银" title="双面烫镭射银">
                        </div>
                    </div>

                </div>
                <div class="layui-form-item pvcCraft" id="pvcCraft" style="display: none">
                    <p>
                        工艺
                    </p>
                    <div class="layui-input-block">
                        <span style="float:left;margin-top:10px">裁切： </span>
                        <input type="radio" name="craftQie" value="圆角" title="圆角" checked/>
                        <input type="radio" name="craftQie" value="异形模切" title="异形模切"/>
                    </div>
                    <div class="layui-input-block">
                        <span style="float:left;margin-top:10px">特殊工艺： </span>
                        <input type="radio" name="craftQieType" value="uv铺白" title="uv铺白" checked/>
                        <input type="radio" name="craftQieType" value="专色uv" title="专色uv"/>
                    </div>
                </div>
                <div class="layui-form-item aromatherCraft" id="aromatherCraft" style="display: none">
                    <p>
                        工艺
                    </p>
                    <div class="layui-form-item" id='z4_craft'>
                        <div class="layui-input-block">
                            印面工艺：
                            <input type="checkbox" name="craft" lay-filter="ui_craft" value="单面" title="单面" checked>
                            <input type="checkbox" name="craft" lay-filter="ui_craft" value="双面" title="双面">
                        </div>
                        <div class="layui-input-block">
                            裁切工艺：
                            <input type="checkbox" name="craft" lay-filter="ui_craft" value="直角裁切" title="直角裁切" checked>
                            <input type="checkbox" name="craft" lay-filter="ui_craft" value="异形模切" title="异形模切">
                        </div>

                        <div class="layui-input-block">
                            常见工艺：
                            <input type="checkbox" name="craft" lay-filter="ui_craft" value="打孔" title="打孔">
                        </div>
                        <div class="layui-input-block">
                            包装：
                            <input type="checkbox" name="craft" lay-filter="ui_craft" value="单独包装" title="单独包装" checked>
                            <input type="checkbox" name="craft" lay-filter="ui_craft" value="真空包装" title="真空包装">
                            <input type="checkbox" name="craft" lay-filter="ui_craft" value="无需包装" title="无需包装">
                        </div>

                        <div class="layui-input-block">
                            配件：
                            <input type="checkbox" class="peijian" name="craft" lay-filter="peijian" value="配涤纶丝带"
                                   title="配涤纶丝带">
                            <input type="checkbox" class="peijian" name="craft" lay-filter="peijian" value="配吊牌绳"
                                   title="配吊牌绳">
                            <input type="checkbox" class="peijian" name="craft" lay-filter="peijian" value="配弹力绳"
                                   title="配弹力绳">
                        </div>
                        <div class="layui-input-block">
                            穿配件：
                            <input type="checkbox" class="peijian" name="craft" lay-filter="peijian" value="穿涤纶丝带"
                                   title="穿涤纶丝带">
                            <input type="checkbox" class="peijian" name="craft" lay-filter="peijian" value="穿吊牌绳"
                                   title="穿吊牌绳">
                            <input type="checkbox" class="peijian" name="craft" lay-filter="peijian" value="穿弹力绳"
                                   title="穿弹力绳">
                            <div class="layui-inline shengz scolor" style="width: 110px;display: none">
                                <select class="select" name="shen_color">
                                    <option value="白色绳子">白色绳子</option>
                                    <option value="黑色绳子">黑色绳子</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-input-block" id="peijian_ui" style="display: none">
                            配件颜色：
                            <div class="layui-inline shengz scolor" style="width: 110px;">
                                <select class="select" name="shen_color">
                                    <option value="白色绳子">白色绳子</option>
                                    <option value="黑色绳子">黑色绳子</option>
                                </select>
                            </div>
                        </div>
                    </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">
        <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'], function () {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        var table = layui.table;

        form.on('radio(kindValue)', function (kindValueData) {
            $(".diycount").hide();
            $(".diycount").find(":input").attr("disabled", true);
            $(".diycount").find("select").attr("disabled", true);
            $(".fixcount").hide();
            $(".fixcount").find(":input").attr("disabled", true);
            $(".fixcount").find("select").attr("disabled", true);
            $(".pvcCraft").hide();
            $(".pvcCraft").find(":input").attr("disabled", true);
            $(".pvcCraft").find("select").attr("disabled", true);
            $(".aromatherCraft").hide();
            $(".aromatherCraft").find(":input").attr("disabled", true);
            $(".aromatherCraft").find("select").attr("disabled", true);
            $("#jtcolor").hide();
            $("#tangcolor").hide();
            $("#tangtype").hide();
            $("#yaao").prop("checked", true);
            $("#size").val("").prop("readonly", false);
            $("#leishe_layout").hide();
            $("#leishe_layout").find(":input").attr("disabled", true);
            $("#leishe_layout").find("select").attr("disabled", true);
            $("#leishe_type").hide();
            $("#leishe_type").find("select").attr("disabled", true);
            $("#huangjin_type").hide();
            $("#huangjin_type").find("select").attr("disabled", true);
            $("#color_type").hide();
            $("#color_type").find("select").attr("disabled", true);
            $("input[name='kind2Value'][value='无']").prop("checked", true);
            if (kindValueData.value == 10 || kindValueData.value == 11) {
                $(".fixcount").show();
                $(".fixcount").find(":input").attr("disabled", false);
                $(".fixcount").find("select").attr("disabled", false);
                $("#size").val("9*9").prop("readonly", true);
            } else if (kindValueData.value == 12) {
                $(".pvcCraft").show();
                $(".pvcCraft").find(":input").attr("disabled", false);
                $(".pvcCraft").find("select").attr("disabled", false);
            } else if (kindValueData.value != 13) {
                $(".diycount").show();
                $(".diycount").find(":input").attr("disabled", false);
                $(".diycount").find("select").attr("disabled", false);
                if (kindValueData.value == '3') {
                    $(".ui_gy_1").show();
                    $(".ui_gy_2").hide();
                } else {
                    $(".ui_gy_1").hide();
                    $(".ui_gy_2").show();

                    if (kindValueData.value == '4') {
                        $('#double').prop('checked', false);
                        $('#non').prop('checked', true);
                        $("#double").parent('span').hide();
                        $('#non').parent('span').show();
                        $("#leishe_layout").show();
                        $("#leishe_layout").find(":input").attr("disabled", false);
                        $("#leishe_layout").find("select").attr("disabled", false);
                    }
                    if (kindValueData.value == '6') {
                        $('#double').prop('checked', true);
                        $('#non').prop('checked', false);
                        $('#non').parent('span').hide();
                        $("#double").parent('span').show();
                        $("#leishe_layout").show();
                        $("#leishe_layout").find(":input").attr("disabled", false);
                        $("#leishe_layout").find("select").attr("disabled", false);
                    }
                }
            } else if (kindValueData.value == 13) {
                $(".aromatherCraft").show();
                $(".aromatherCraft").find(":input").attr("disabled", false);
                $(".aromatherCraft").find("select").attr("disabled", false);
                $(".pvcCraft")
            }

            form.render();
            getProductImage()
        })

        form.on("radio(switch)", function (data) {
            $("#jtcolor").hide();
            $("#jtcolor").find(":input").attr("disabled", true);
            $("#tangcolor").hide();
            $("#tangtype").hide();
            $("#tangcolor").find(":input").attr("disabled", true);
            $("#tangtype").find(":input").attr("disabled", true);
            if ($(data.elem).is(":checked") && data.value == "击凸") {
                $("#jtcolor").show();
                $("#jtcolor").find(":input").attr("disabled", false);
            }
            $("input[name='tcolor']").prop("checked", false);
            if ($(data.elem).is(":checked") && data.value == "烫金") {
                $("#tangcolor").show();
                $("#tangcolor").find(":input").attr("disabled", false);
                $("#tangcolor input[name='tcolor']")[0].checked = true;
            }
            if ($(data.elem).is(":checked") && data.value == "烫镭射银") {
                $("#tangtype").show();
                $("#tangtype").find(":input").attr("disabled", false);
                $("#tangtype input[name='tcolor']")[0].checked = true;
            }
            form.render();
        });
        form.on("checkbox(color)", function (data) {
            if ($("input[name='jtcolor']:checked").length > 2) {
                $(data.elem).next().attr("class", "layui-unselect layui-form-checkbox");
                $(data.elem).prop("checked", false);
                layer.msg('击凸颜色最多选择两个！', {offset: ['300px', '300px']}, {icon: 5});
                return false;
            }
        });
        form.on('radio(kind2Value)', function (data) {
            let at = data.value;
            if (at == '击凸' || at == '压凹' || at == '单面烫金+压凹' || at == '单面烫金+击凸') {
                if (at.indexOf("击凸") > -1) {
                    $("#color_type select").empty().append(` <option value="无色" selected>无色</option>
                    <option value="有色">有色</option>
                    <option value="有色加激凸">有色加激凸</option>`)
                }
                if (at.indexOf("压凹") > -1) {
                    $("#color_type select").empty().append(` <option value="无色" selected>无色</option>
                    <option value="有色">有色</option>
                    <option value="有色加压凹">有色加压凹</option>`)
                }
                $("#color_type").show();
                $("#color_type").find("select").attr("disabled", false);
            } else {
                $("#color_type").hide();
                $("#color_type").find("select").attr("disabled", true);
            }
            if (at == '烫镭射银') {
                $("#leishe_type").show();
                $("#leishe_type").find("select").attr("disabled", false);
            } else {
                $("#leishe_type").hide();
                $("#leishe_type").find("select").attr("disabled", true);
            }
            if (at == '烫黄金') {
                $("#huangjin_type").show();
                $("#huangjin_type").find("select").attr("disabled", false);
            } else {
                $("#huangjin_type").hide();
                $("#huangjin_type").find("select").attr("disabled", true);
            }
            form.render();
        })

        function getProductImage(craft) {

            $("#carousel").empty();
            $("#remark").empty();
            let data = {proTypeValue: "杯垫"}
            let remark = "";
            let html = "";
            let kindValue = $("input[name='kindValue']:checked").val();
            if (!!kindValue) {
                if (kindValue == 4 || kindValue == 6) {
                    kindValue = "铜版纸";
                }
                data.kindValue = kindValue;
            }
            if (kindValue == 13) {
                data.proTypeValue = "香薰卡";
                delete data.kindValue;
            }
            $.ajax({
                url: "${pageContext.request.contextPath}/getImgs",
                type: "GET",
                data,
                //dataType : "json",
                success: function (result) {
                    for (let i = 0; i < result.length; i++) {
                        // 只留一个remark
                        remark = "";
                        if (result[0].imgWidth < result[0].imgHeight) {
                            html += '<div><img style="width:' + result[0].imgWidth + 'px" src="' + result[i].imgUrl + '"></div>';
                        } else {
                            html += '<div><img style="height:' + result[0].imgHeight + 'px" 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
                        });
                    }
                }
            });
        };
        const carft_list1 = ["单面", "双面"];

        const carft_list2 = ["直角裁切", "异形模切"];

        const carft_list3 = ["单独包装", "真空包装", "无需包装"];

        const carft_list4 = ["穿涤纶丝带", "穿吊牌绳", "穿弹力绳"];
        const carft_list5 = ["配涤纶丝带", "配吊牌绳", "配弹力绳"];
        form.on('checkbox(ui_craft)', function (data) {
            let craft_list = [];
            craft_list.push($("select[name='craft'] option:selected").val());
            $("input[name='craft']:checked").each(function () {
                    if (!$(this).is(':disabled')) {
                        craft_list.push($(this).val());
                    }
                }
            );

            const carft1 = carft_list1.filter(craft => craft_list.includes(craft));
            if (carft1.length > 1) {
                $(data.elem).prop("checked", false);
                layer.msg("印面工艺不能同时选择", {offset: ['300px', '300px']}, function () {
                });
                form.render();
                return false;
            }
            const carft2 = carft_list2.filter(craft => craft_list.includes(craft));
            if (carft2.length > 1) {
                $(data.elem).prop("checked", false);
                layer.msg("裁切工艺不能同时选择", {offset: ['300px', '300px']}, function () {
                });
                form.render();
                return false;
            }
            const carft3 = carft_list3.filter(craft => craft_list.includes(craft));
            if (carft3.length > 1) {
                $(data.elem).prop("checked", false);
                layer.msg("包装工艺不能同时选择", {offset: ['300px', '300px']}, function () {
                });
                form.render();
                return false;
            }

            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();
                return false;
            }
        })
        form.on('checkbox(peijian)', function (data) {
            let craft_list = [];
            $(".peijian:checked").each(function () {
                    if (!$(this).is(':disabled')) {
                        craft_list.push($(this).val());
                    }
                }
            );
            const carft4 = carft_list4.filter(craft => craft_list.includes(craft));
            const carft5 = carft_list5.filter(craft => craft_list.includes(craft));
            if (carft4.length > 0 && carft5.length > 0) {
                $(data.elem).next().attr("class", "layui-unselect layui-form-checkbox");
                $(data.elem).prop("checked", false);
                layer.msg('配 - 穿只能选择一种！', {offset: ['300px', '300px']}, {icon: 5});
                return false;
            }
            if (carft4.length > 1) {
                $(data.elem).next().attr("class", "layui-unselect layui-form-checkbox");
                $(data.elem).prop("checked", false);
                layer.msg('穿只能选择一种！', {offset: ['300px', '300px']}, {icon: 5});
                return false;
            }
            if ($(data.elem).is(":checked")) {
                $("#peijian_ui").show();
                $("#peijian_ui .scolor select").prop("disabled", false);
            } else {
                $("#peijian_ui").hide();
                $("#peijian_ui .scolor select").prop("disabled", true);
            }
            form.render();
        })
        // 点击计算，计算价格
        form.on('submit(acount_btn)', function (data) {

            // 选中‘自定义数量’
            var kindValue = $('input[name="kindValue"]:checked').val();
            var kind2Value = $('input[name="kind2Value"]:checked').val();
            var craftQie = $('input[name="craftQie"]:checked').val();
            var craftMo = $('input[name="craftMo"]:checked').val();
            var size = $("#size").val();
            var count = $("select[name='count'] option:selected").text();
            var craftTang = $('input[name="craftTang"]:checked').val();
            var arr = [];
            arr.push(craftMo);
            if (!kindValue) {
                layer.msg("请选择材质", {offset: ['300px', '300px']}, function () {
                });
                return false;
            }
            if (kindValue == 4) {
                if ((size.split("*")[0] < 3 || size.split("*")[1] < 3)) {
                    layer.msg("【杯垫900克】尺寸不能低于3*3 cm!", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
            }
            $("#proTypeValue").val("杯垫");
            if ((kindValue == 3)) {
                if (craftQie == "异形模切") {
                    if ((size.split("*")[0] > 21 || size.split("*")[1] > 21)) {
                        layer.msg("【900克双胶纸】尺寸不能小于21*21 cm!", {offset: ['300px', '300px']}, function () {
                        });
                        return false;
                    }
                    if ((size.split("*")[0] <= 9 && size.split("*")[1] <= 5.4) || (size.split("*")[0] <= 5.4 && size.split("*")[1] <= 9)) {
                        if (craftTang) {
                            if (craftTang == "单面烫金") {
                                $("#proTypeValue").val(3);
                            }
                        } else {
                            if ((size.split("*")[0] < 3 || size.split("*")[1] < 3)) {
                                $("#proTypeValue").val(3);
                                $("input[name='kindValue']:checked").val(0);
                            } else {
                                $("#proTypeValue").val("杯垫");
                            }
                        }
                        form.render();
                    }
                }
            }
            let craft = $("input[name='craft']:checked").val();
            if (craft == "击凸" && $("input[name='jtcolor']:checked").length == 0) {
                layer.msg("【击凸】颜色必须选一个!", {offset: ['300px', '300px']}, function () {
                });
                return false;
            }
            var number = $("#number").val();

            if (kindValue == "12") {

                if ((size.split("*")[0] < 5 || size.split("*")[1] < 5)) {
                    layer.msg("【PVC】最小尺寸5*5!", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
                if ((size.split("*")[0] > 10 || size.split("*")[1] > 10)) {
                    layer.msg("【PVC】最大尺寸10*10!", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }

            }
            if (kindValue == "13") {
                arr = [];
                if ((size.split("*")[0] > 42 || size.split("*")[1] > 28.5) && (size.split("*")[1] > 42 || size.split("*")[0] > 28.5)) {
                    layer.msg('最大尺寸42*28.5cm！', {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
                if ((size.split("*")[0] < 1 || size.split("*")[1] < 1)) {
                    layer.msg('最小尺寸1*1cm！', {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
                arr.push($("#xiangwei select[name='craft'] option:selected").val());
                arr.push($(".aromatherCraft select[name='kind'] option:selected").text());
                $("input:checkbox[name='craft']:checked").each(function (i) {
                    // 没有被禁用的工艺加到arr中
                    if (!$(this).is(':disabled')) {
                        if (carft_list4.indexOf($(this).val()) > -1) {
                            arr.push($(this).val() + $("#peijian_ui select[name='shen_color'] option:selected").val());
                        } else if ($(this).val() == "抠图") {
                            arr.push($(this).val() + $("input[name='cropNumber']").val());
                            return;
                        } else {
                            arr.push($(this).val());
                        }
                    }
                });

                const carft1 = carft_list1.filter(item => arr.includes(item));
                if (carft1.length == 0) {
                    layer.msg("请选择印面工艺", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
                const carft2 = carft_list2.filter(item => arr.includes(item));
                if (carft2.length == 0) {
                    layer.msg("请选择裁切工艺", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
                const carft3 = carft_list3.filter(item => arr.includes(item));
                if (carft3.length == 0) {
                    layer.msg("请选择包装工艺", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
            }
            kindValueData = {
                3: "350克铜版纸",
                6: "600克铜版纸",
                4: "900克双胶纸",
                10: "轻羽",
                11: "简单",
                12: "透明PVC",
                13: "香薰卡"
            };
            $.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;
                    }
                    var data = result.data.proList;
                    if ("无" != kind2Value) {

                        if (kind2Value == "击凸" || kind2Value == "压凹" || kind2Value == "单面烫金+压凹" || kind2Value == "单面烫金+击凸") {
                            arr.push(kind2Value + $("#color_type select[name='craft'] option:selected").val())
                        } else if (kind2Value == '烫镭射银') {
                            arr.push($("#leishe_type select[name='craft'] option:selected").val())
                        } else if (kind2Value == '烫黄金') {
                            arr.push($("#huangjin_type select[name='craft'] option:selected").val())
                        } else {
                            arr.push(kind2Value)
                        }
                    }
                    var span_result = '杯垫 - ' + kindValueData[kindValue] + ' - ' + size + '厘米\n'
                    if (kindValue == "3" || kindValue == "4" || kindValue == "6") {
                        span_result += "工艺： " + craftQie + ', ' + arr + "\n";
                    } else if (kindValue == "12") {
                        let craftQie = $("input[name='craftQie']:checked").val();
                        let craftQieType = $("input[name='craftQieType']:checked").val();
                        let size1 = $("select[name='size1'] option:selected").val();
                        let craft_list = ['规格' + size1, craftQie, craftQieType];
                        span_result += "工艺： " + craft_list.join(",") + "\n";
                    } else if (kindValue == "13") {
                        span_result += `工艺：` + arr.join(",") + '\n';
                    } else {
                        let aotu = $("input[name='aotu']:checked").val();
                        let craft = $("input[name='craft']:checked").val();
                        let craft_list = [aotu];

                        if (craft == "击凸") {
                            let ys = $("input[name='jtcolor']:checked");
                            ys.each(item => {
                                craft_list.push($(ys[item]).val());
                            })
                        } else if (craft == "烫金") {
                            let ys = $("input[name='tcolor']:checked").val();
                            craft_list.push(ys);
                        } else if (craft == "烫镭射银") {
                            let ys = $("input[name='tcolor']:checked").val();
                            craft_list.push(ys);
                        } else {
                            craft_list.push(craft);
                        }
                        span_result += "工艺： " + craft_list.join(",") + "\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);
                    var craft = craftQie + arr;
                    getRemark("杯垫", size, count + "张", kindValueData[kindValue], number, craft, "");
                    //计算完自动复制文本
                    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: 'wangwang',
                            align: "center",
                            width: '16%',
                            title: '折扣价'
                        }, {
                            field: 'wangwang',
                            align: "center",
                            width: '19%',
                            title: '跳楼价'
                        }, {
                            field: 'weight',
                            width: '21%',
                            align: "center",
                            title: '重量（kg）'
                        }]],
                        done: function () {
                        }
                    });
                }
            });
            return false;
        });
    });
</script>
</html>