<%@ 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;
    }

    .shengz .layui-edge {
        right: 40px;
    }

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

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

    .dakongHide .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">
            <div class="layui-form-item">
                <input type="radio" lay-filter="stickerKind" name="stickerKind" value="常规" title="常规" checked="checked">
                <!--<input type="radio" lay-filter="stickerKind" name="stickerKind" value="少数量" title="少数量">-->
            </div>
        </form>
        <form class="layui-form">
            <input type="hidden" name="proTypeValue" id="proTypeValue" class="layui-input" value="服装吊牌">
            <p>材质</p>
            <div class="ui_normal">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="3" title="350克铜版纸">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="6" title="600克铜版纸">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="4" title="900克双胶纸">
            </div>
            <div class="ui_less" style="display: none;">
                <input type="radio" name="kindValue" lay-filter="kindValue" value="3" title="350克铜版纸">
            </div>
            <div class="tagOther">
                <p>
                    尺寸(CM/厘米) <span style="font-size: 14px; color: red">输入格式: 长 * 宽</span>
                    <span class="addOrCutClothes">
<%--							<button type="button" title="点击添加尺寸" class="layui-btn layui-btn-primary layui-btn-sm button"--%>
<%--                                    onclick="AddInputClothes()"><i class="layui-icon">组合</i></button>--%>
							<button type="button" title="点击移除尺寸" class="layui-btn layui-btn-primary layui-btn-sm button"
                                    onclick="CutInputClothes()"><i class="layui-icon">单张</i></button>
						</span>
                </p>
                <div class="qt">
                    <div class="layui-form-item" id="fatherDivClothes">
                        <input type="text" name="size" placeholder="格式:长*宽" id="size" class="layui-input"
                               autocomplete="off">
                    </div>
                </div>

                <p>
                    数量(张) <span class="switchCount">
						<input type="checkbox" name="switchCount" class="Count" lay-filter="switchCount" title="自定义数量"></span>
                </p>
                <div class="count">
                    <div class="layui-form-item">
                        <select name="count" id="zjCount" class="select">
                            <option value="200">200</option>
                            <option value="500">500</option>
                            <option value="1000">1000</option>
                            <option value="2000">2000</option>
                            <option value="3000">3000</option>
                            <option value="4000">4000</option>
                            <option value="5000">5000</option>
                            <option value="10000">10000</option>
                        </select>
                    </div>
                </div>
                <div class="mqCount" style="display:none">
                    <div class="layui-form-item">
                        <select name="count" id="mqCount" 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>
                            <option value="20000">20000</option>
                        </select>
                    </div>
                </div>
                <div class="diyCount" style="display: none">
                    <div class="layui-form-item">
                        <input type="text" name="count" id="count" placeholder="请输入整数" class="layui-input"
                               autocomplete="off">
                    </div>
                </div>
                <p>款数</p>
                <div class="layui-form-item">
                    <input type="text" placeholder="请输入整数" autocomplete="off"
                           name="number" id="number" value="1" class="layui-input">
                </div>
                <p>
                    客户旺旺
                </p>
                <div class="layui-form-item">
                    <input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
                           class="layui-input">
                </div>
                <div class="ui_normal">
                    <p>
                        工艺
                    </p>
                    <div class="layui-input-block">
                        <div class="layui-input-block">
                            裁切工艺：
                            <input type="radio" name="craftQie" lay-filter="craftQie" la value="直角裁切" title="直角裁切"
                                   checked>
                            <input type="radio" name="craftQie" lay-filter="craftQie" value="异形模切" title="异形模切">
                        </div>
                        <div class="layui-input-block">
                            覆膜工艺：
                            <input type="radio" name="craftMo" lay-filter="craftMo" la value="双面覆哑膜" title="双面覆哑膜"
                                   checked>
                            <%--                            <input type="radio" name="craftMo" lay-filter="craftMo" value="不覆膜" title="不覆膜">--%>
                        </div>
                        <div class="layui-input-block">
                            烫金工艺：
                            <input type="checkbox" class="tang" name="craftTang" lay-filter="switch" value="单面烫金"
                                   title="单面烫金" lay-skin="primary">
                            <input type="checkbox" class="tang" name="craftTang" lay-filter="switch" value="双面烫金"
                                   title="双面烫金" lay-skin="primary">
                            <span class="sizeTang">
                                <div class="layui-inline">
                                    <input type="text" placeholder="长边" autocomplete="off" name="lengthTang"
                                           id="lengthTang" disabled class="layui-input" style="width:50px;height:35px;">
                                </div>x
                                <div class="layui-inline">
                                    <input type="text" placeholder="短边" autocomplete="off" name="widthTang"
                                           id="widthTang" disabled class="layui-input" style="width:50px;height:35px;">
                                </div>
                            </span>
                        </div>
                        <div class="layui-input-block">
                            常见工艺：
                            <input type="checkbox" name="aotu" lay-filter="switch" value="击凸" title="击凸"
                                   lay-skin="primary">
                            <input type="checkbox" name="aotu" lay-filter="switch" value="压凹" title="压凹"
                                   lay-skin="primary">
                            <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>
                            <input type="checkbox" name="craft" lay-filter="switch" value="打孔" title="打孔"
                                   lay-skin="primary" checked>
                            <div class="layui-inline edge dakongHide" style="width:80px;">
                                <select class="select wkong layui-inline">
                                    <option value="3mm" selected>3mm</option>
                                    <option value="5mm">5mm</option>
                                </select>
                            </div>
                        </div>
                        <div class="craft_lius">
                            配件：
                            <input type="checkbox" class="lius" name="craft" lay-filter="ui_lius" value="流苏" title="流苏">
                            <input type="checkbox" class="biez" name="craft" lay-filter="ui_lius" value="别针" title="别针">
                            <input type="checkbox" class="shengz" name="craft" lay-filter="ui_lius" value="绳子"
                                   title="绳子">
                            <div class="shengz scolor" style="width: 150px;display: none">
                                <select class="select">
                                    <option value="白色绳子">白色绳子</option>
                                    <option value="黑色绳子">黑色绳子</option>
                                    <option value="红色绳子">红色绳子</option>
                                </select>
                            </div>
                            <input type="checkbox" class="miansheng" name="craft" lay-filter="ui_lius" value="配棉绳"
                                   title="配棉绳">
                            <input type="checkbox" class="tshengz" name="craft" lay-filter="ui_lius" value="弹力绳"
                                   title="弹力绳（15cm）">
                            <input type="checkbox" class="tshengz" name="craft" lay-filter="ui_lius" value="弹力绳捆"
                                   title="弹力绳（捆）">
                            <div class="shengz tscolor" style="width: 150px;display: none">
                                <select class="select">
                                    <option value="金色绳子">金色绳子</option>
                                    <option value="银色绳子">银色绳子</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

            <div id="tag" style="display: none">
                <%@include file="tag.jsp" %>
            </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>
            <!--<h2>下单备注-<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult" onclick="copyBz()">点击复制</button></h2>
            <div>
                <textarea rows="5" cols="75" id="bz_result" readonly="readonly"></textarea>
            </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>
    //用来判断是删除 还是增加按钮 以便count值进行计算
    var countClothes = 0;

    function AddInputClothes() {
        if (countClothes > 0) {
            return false;
        }
        countClothes++;
        var fatherDivClothes = document.getElementById("fatherDivClothes");

        //创建input
        var input = document.createElement("input");
        input.type = "text";
        input.setAttribute('class', 'layui-input');
        input.name = "size" + countClothes;
        input.placeholder = "格式:长*宽";
        input.autocomplete = "off";
        input.setAttribute('class', 'layui-input size2');
        fatherDivClothes.appendChild(input);
    }

    function CutInputClothes() {
        countClothes = 0;
        $(".size2").remove();
    }


    layui.use(['table', 'form', 'carousel'], function () {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        var table = layui.table;
        var carousel = layui.carousel;
        //建造实例
        getRemoker()
        ins = carousel.render({});

        function getRemoker() {
            let kindValue = $("input[name='kindValue']:checked").val();
            let kind2Value = $("input[name='kind2Value']:checked").val();
            let craftQie = $("input[name='craftQie']:checked").val();
            let craftTang = $("input[name='craftTang']:checked").val();
            let auto = $("input[name='aotu']:checked").val();

            $("#remark").empty();
            let html = "预计发货时间:<br>";
            if (kindValue == "3") {
                if (craftQie == "直角裁切" && !craftTang && !auto) {
                    html += "福建：(2天发货) 圆通 顺丰<br>"
                    html += "广东：(2天发货) 中通 顺丰<br>"
                }
                if (craftQie == "直角裁切" && craftTang == "单面烫金") {
                    html += "福建：直角裁切、单面烫金(3-4天发货) 圆通 顺丰<br>"
                    html += "广东：直角裁切、单面烫金(3-4天发货) 中通 顺丰<br>"
                }
                if (craftQie == "直角裁切" && craftTang == "双面烫金") {
                    html += "福建：直角裁切、双面烫金(3-4天发货) 圆通 顺丰<br>"
                    html += "广东：直角裁切、双面烫金(3-4天发货) 中通 顺丰<br>"
                }
                if (craftQie == "异形模切" && !craftTang && !auto) {
                    html += "福建：异形模切(3-4天发货) 圆通 顺丰<br>"
                    html += "广东：异形模切(3-4天发货) 中通 顺丰"
                }
                if (craftQie == "异形模切" && craftTang == "单面烫金") {
                    html += "福建：异形模切、单面烫金(4-5天发货) 圆通 顺丰<br>"
                    html += "广东：异形模切、单面烫金(4-5天发货) 中通 顺丰<br>"
                }
                if (craftQie == "异形模切" && craftTang == "双面烫金") {
                    html += "福建：异形模切、双面烫金(4-5天发货) 圆通 顺丰<br>"
                    html += "广东：异形模切、双面烫金(4-5天发货) 中通 顺丰<br>"
                }
                if (craftQie == "直角裁切" && (auto == "击凸" || auto == "压凹")) {
                    html += "福建：直角裁切、击凸、压凹(3-4天发货) 圆通 顺丰<br>"
                    html += "广东：直角裁切、击凸、压凹(3-4天发货) 中通 顺丰<br>"
                }
                if (craftQie == "异形模切" && (auto == "击凸" || auto == "压凹")) {
                    html += "福建：异形模切、击凸、压凹(4-5天发货) 圆通 顺丰<br>"
                    html += "广东：异形模切、击凸、压凹(4-5天发货) 中通 顺丰<br>"
                }
            }

            if (kindValue == 6) {
                if (kind2Value == "无") {
                    html += "福建：(5-7天发货) 圆通 顺丰<br>"
                } else {
                    html += "福建：(5-7天发货) 圆通 顺丰<br>"
                }
            }
            if (kindValue == 4) {
                if (kind2Value == "无") {
                    html += "福建：(5-7天发货) 圆通 顺丰<br>"
                } else {
                    html += "福建：(5-7天发货) 圆通 顺丰<br>"
                }
            }
            let remark = '<div><span>' + html + '<span/></div>';
            $("#remark").append(remark);
            getProductImage()
        }

        function getProductImage() {
            $("#carousel").empty();
            $(".layui-carousel-ind").remove();
            let kindValue = $("input[name='kindValue']:checked").val();
            let craftQie = $("input[name='craftQie']:checked").val();
            let kind2Value = $("input[name='kind2Value']:checked").val();
            let craftMo = $("input[name='craftMo']:checked").val();
            let craftTang = $("input[name='craftTang']:checked").val();
            let auto = $("input[name='aotu']:checked").val();
            let craft = $("input[name='craft']:checked").val();
            let data = {proTypeValue: '服装吊牌'}
            if (kindValue == 3) {
                if (craftMo == '双面覆哑膜' && !craftTang && !auto) {
                    data.craftValue = 0;
                    if (craftQie == '异形模切') {
                        data.craftValue = 5;
                    }
                }
                if (craftMo == '不覆膜' && !craftTang && !auto) {
                    data.craftValue = 1;
                    if (craftQie == '异形模切') {
                        data.craftValue = 5;
                    }
                }
                if (craftTang && !auto) {
                    data.craftValue = 2;
                }
                if (!craftTang && auto) {
                    data.craftValue = 3;
                }
                if (craftTang && auto) {
                    data.craftValue = 4;
                }
                if (craft == '流苏') {
                    data.craftValue = '流苏';
                }

            } else {
                if (kind2Value != '无') {
                    data.craftValue = kind2Value;
                }
            }

            let html = "";
            $.ajax({
                url: "${pageContext.request.contextPath}/getImgs",
                type: "GET",
                data,
                //dataType : "json",
                success: function (result) {
                    for (let i = 0; i < result.length; i++) {
                        // 只留一个remark
                        html += '<div><img style="width:' + result[0].imgWidth + 'px" src="' + result[i].imgUrl + '"></div>';
                    }
                    $("#carousel").append(html);
                    // 如果没有轮播图就隐藏
                    if (result.length == 0) {
                    } else {
                        document.getElementById("test1").style.display = "block";   //显示
                        ins.reload({
                            elem: '#test1',
                            width: result[0].imgWidth,  //设置容器宽度
                            height: result[0].imgHeight
                        });
                    }
                }
            });
        }

        form.on('radio(craftMo)', function () {
            getProductImage()
        })
        form.on('checkbox(ui_lius)', function (data) {
            getProductImage()
            let shengz = $(".shengz:checked").length;
            let tshengz = $(".tshengz:checked").length;
            if (shengz == 1 && tshengz == 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 (tshengz > 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 (shengz == 1) {
                $(".scolor").css("display", "inline-block")
            } else {
                $(".scolor").hide()
            }
            if (tshengz == 1) {
                $(".tscolor").css("display", "inline-block")
            } else {
                $(".tscolor").hide()
            }
        })
        form.on('radio(stickerKind)', function (stickerKindData) {
            if (stickerKindData.value == "常规") {
                $(".ui_normal").show();
                $(".ui_less").hide();
                $(".ui_normal").find(":input").attr("disabled", false);
            } else {
                $(".ui_less").show();
                $(".ui_normal").hide();
                $(".ui_normal").find(":input").attr("disabled", true);
            }
            form.render();
        });
        form.on('radio(kind2Value)', function (data) {
            let at = data.value;
            if (at == '击凸' || at == '压凹') {
                if (at.indexOf("击凸") > -1) {
                    $("#tcolor_type select").empty().append(` <option value="无色" selected>无色</option>
                    <option value="有色">有色</option>
                    <option value="有色加激凸">有色加激凸</option>`)
                }
                if (at.indexOf("压凹") > -1) {
                    $("#tcolor_type select").empty().append(` <option value="无色" selected>无色</option>
                    <option value="有色">有色</option>
                    <option value="有色加压凹">有色加压凹</option>`)
                }
                $("#tcolor_type").show();
                $("#tcolor_type").find("select").attr("disabled", false);
            } else {
                $("#tcolor_type").hide();
                $("#tcolor_type").find("select").attr("disabled", true);
            }
            getRemoker();
            form.render();
        })
        form.on('checkbox(switch)', function (data) {
            // 压痕压点线只能选一个
            var tangLen = $(".tang:checked").length;
            if (tangLen > 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 (tangLen == 0) {
                $(".sizeTang input").attr("disabled", true)
            }
            if (tangLen > 0) {
                $(".sizeTang input").attr("disabled", false)
            }
            var at = $("input[name='aotu']:checked").val();
            if (tangLen == 1 && at != null) {
                $(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 ($("input[name='aotu']:checked").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 (at != null) {
                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);
            }
            var craftSheng = $(".craftSheng2:checked").length;
            if (craftSheng == 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;
            }
            if (data.value == "配弹力绳" || data.value == "配弹力绳捆") {
                if ($(data.elem).is(":checked")) {
                    $(".craftSheng .tscolor").show();
                    $(".craftSheng .tscolor").prop("disabled", false);
                } else {
                    $(".craftSheng .tscolor").hide();
                    $(".craftSheng .tscolor").prop("disabled", true);
                }
            }
            if (!data.elem.checked && data.value == "打孔") {
                layer.msg('不能取消 [打孔] 工艺！', {offset: ['300px', '300px']}, function () {
                });
                $(data.elem).prop("checked", true);
            }
            form.render();
            getRemoker()
        })

        // 默认禁用600克
        $("#tag").find(":input").attr("disabled", true);
        form.on('radio(kindValue)', function (kindValueData) {
            $('input[class = craftSheng]').prop('checked', false);
            $('input[class = craftSheng2]').prop('checked', false);
            var stickerKind = $("input[name='stickerKind']:checked").val();
            $(".craft_lius").hide();
            $(".craft_lius input").prop("disabled", true);
            $(".craft_lius input").prop("checked", false);
            $(".scolor").hide()
            form.render();

            if (stickerKind == "常规") {
                if (kindValueData.value == '3') {
                    $(".switchCount").show();
                    if (craftQie == "直角裁切") {
                        $(".count").show();
                        $(".count").find(":input").attr("disabled", false);
                    }
                    $(".diyCount").hide();
                    $(".diyCount").find(":input").attr("disabled", true);
                    $("#selectCount").attr("disabled", false);

                    $(".tagOther").show();
                    $(".tagOther").find(":input").attr("disabled", false);
                    $("#tag").hide();
                    $("#tag").find(":input").attr("disabled", true);
                    $(".craft_lius").show();
                    $(".craft_lius checkbox[name='craft']").attr("disabled", false);
                    form.render();
                } else {
                    $("input[name='kind2Value'][value='无']").prop('checked', true);
                    $("#leishe_layout").hide();
                    $("#leishe_layout").find(":input").attr("disabled", true);
                    $("#tcolor_type").hide();
                    $("#tcolor_type").find(":input").attr("disabled", true);
                    if (kindValueData.value == 6) {
                        $("#leishe_layout").show();
                        $("#leishe_layout").find(":input").attr("disabled", false);
                    }
                    $(".addOrCut").show();
                    $('input[class = Count]').prop('checked', false);
                    $(".switchCount").hide();
                    $(".diyCount").show();
                    $(".count").hide();
                    $(".diyCount").find(":input").attr("disabled", false);
                    $(".count").find(":input").attr("disabled", true);
                    $("#selectCount").attr("disabled", true);

                    $(".tagOther").hide();
                    $(".tagOther").find(":input").attr("disabled", true);
                    $("#tag").show();
                    $("#tag").find(":input").attr("disabled", false);


                    form.render();
                }
            } else {
                $('input[class = Count]').prop('checked', false);
                $(".switchCount").hide();
                $(".diyCount").show();
                $(".count").hide();
                $(".diyCount").find(":input").attr("disabled", false);
                $(".count").find(":input").attr("disabled", true);
                $("#selectCount").attr("disabled", true);
                $("#mqCount").attr("disabled", true);
                form.render();
            }
            if (kindValueData.value == 3) {
                $(".sizeTang").show()
            } else {
                $(".sizeTang").hide()
            }
            $(".sizeTang input").attr("disabled", true)
            getRemoker()
        })

        $("#mqCount").attr("disabled", true);
        // 默认直角打孔，禁用第二尺寸
        // $(".addOrCutClothes").hide();
        var craftQie = "直角裁切";
        form.on('radio(craftQie)', function (data) {
            // 选中工艺标识
            craftQie = data.value;
            // 自定义数量没选中
            if (data.value == "直角裁切") {
                // 禁用第二尺寸
                // $(".addOrCutClothes").hide();
                countClothes = 0;
                // $(".size2").remove();
                if (!choose) {
                    $(".mqCount").hide();
                    $(".count").show();
                    $("#mqCount").attr("disabled", true);
                    $("#zjCount").attr("disabled", false);
                }
            } else {
                // $(".addOrCutClothes").show();
                if (!choose) {
                    $(".count").hide();
                    $(".mqCount").show();
                    $("#zjCount").attr("disabled", true);
                    $("#mqCount").attr("disabled", false);
                }
            }

            form.render();
            getRemoker()
        })

        // 自定义数量是否选中标识
        var choose;
        // 自定义少数量
        form.on('checkbox(switchCount)', function (data) {
            if (data.elem.checked) {
                choose = true;
                $(".diyCount").show();
                $(".count").hide();
                $(".mqCount").hide();
                $(".diyCount").find(":input").attr("disabled", false);
                $("#mqCount").attr("disabled", true);
                $("#zjCount").attr("disabled", true);
            } else {
                choose = false;
                if (craftQie == "直角裁切") {
                    $(".count").show();
                    $("#zjCount").attr("disabled", false);
                } else {
                    $(".mqCount").show();
                    $("#mqCount").attr("disabled", false);
                }
                $(".diyCount").hide();
                $(".diyCount").find(":input").attr("disabled", true);
                // 恢复标准数量的时候会被禁用，加这个解决
                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) {
            /* var wangwang = $("#wangwang").val();
            if(wangwang == ""){
                layer.msg("请填写客户旺旺号！",{offset:['300px','300px']},function(){});
                return false;
            } */
            // 选中‘自定义数量’
            if ($('input[name="switchCount"]:checked').length != 0) {
                if ($("#count").val() < 10000 || $("#count").val() % 1000 != 0) {
                    layer.msg("自定义数量需要大于10000 且是1000的整数倍", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
            }

            var stickerKind = $("input[name='stickerKind']:checked").val();
            var kindValue = $('input[name="kindValue"]:checked').val();
            var craftQie = $('input[name="craftQie"]:checked').val();
            var craftMo = $('input[name="craftMo"]:checked').val();
            var craftTang = $('input[name="craftTang"]:checked').val();
            var craftSheng = $('input[name="craftSheng"]:checked').val();
            var craftAotu = $("input[name='aotu']:checked").val();
            var size = $("#size").val();
            var arr = [];
            arr.push(craftMo);
            if (craftTang) {
                arr.push(craftTang);
            }
            if (!kindValue) {
                layer.msg("请选择材质", {offset: ['300px', '300px']}, function () {
                });
                return false;
            }
            if (kindValue == 4) {
                size = $("#diySize").val();
                if (size.split("*")[0] < 4 || size.split("*")[1] < 4) {
                    layer.msg("【服装吊牌900克双胶纸】尺寸不能小于4*4 cm!", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
            }
            if (kindValue == 6) {
                size = $("#diySize").val();
                if (size.split("*")[0] < 3 || size.split("*")[1] < 3) {
                    layer.msg("【服装吊牌600克铜版纸】尺寸不能小于3*3 cm!", {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
            }
            if ((kindValue == 3 || kindValue == 0)) {
                if (craftQie == "异形模切") {
                    if ((size.split("*")[0] > 21 || size.split("*")[1] > 21)) {
                        layer.msg("【服装吊牌350克】尺寸不能超过21*21 cm!", {offset: ['300px', '300px']}, function () {
                        });
                        return false;
                    }

                }
            }
            if (kindValue == 3 && (craftTang === '单面烫金' || craftTang === '双面烫金')) {
                $(".sizeTang").find(":input").attr("disabled", false);
                if ($("#lengthTang").val() == '' || $("#widthTang").val() == '') {
                    layer.msg('请填写烫金版尺寸！', {offset: ['300px', '300px']}, function () {
                    });
                    return false;
                }
            }
            var number = $("#number").val();
            kindValueData = {
                3: "350克铜版纸",
                4: "900克双胶纸",
                6: "600克铜版纸",
            };
            $("input[name='craft']:checked").each(function () {
                if (!$(this).is("disabled")) {
                    if ($(this).val() == "抠图") {
                        arr.push($(this).val() + $("input[name='cropNumber']").val());
                        return;
                    }
                }
            })
            $.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;
                    let shengku = false;
                    var count = 0;
                    if (kindValue == "3") {
                        if ($("input[name='switchCount']:checked").val() == undefined) {
                            count = $("#zjCount option:selected").val();
                        } else {
                            count = $("#count").val();
                        }
                    } else {
                        count = $("#mqCount option:selected").val();
                    }
                    if ($('input[name="kindValue"]:checked').val() == "4") {
                        craftQie = ""
                        var size1 = $(".size1").val();
                        size = $("#diySize").val();
                        if ((size.split("*")[0] < 3 || size.split("*")[1] < 3)) {
                            layer.msg("[ 服装吊牌900克双胶纸 ] 尺寸小于 3cm 请单独报价", {offset: ['300px', '300px']}, function () {
                            });
                            return false;
                        }
                        if (size1) {
                            if ((size1.split("*")[0] < 3 || size1.split("*")[1] < 3)) {
                                layer.msg("[ 服装吊牌900克双胶纸 ] 尺寸小于 3cm 请单独报价", {offset: ['300px', '300px']}, function () {
                                });
                                return false;
                            }
                            size = size + '厘米，' + size1
                        }
                        number = $("#numberTag").val();
                        arr = []
                        //arr = $('input[name="kind2Value"]:checked').val();
                        // arr.push("双面哑膜");
                        let shengcraft = $("input[name='craftSheng']:checked").val();
                        let szColor = $(".craftSheng select option:selected").val();
                        if (shengcraft == "配弹力绳") {
                            arr.push(szColor + "配弹力绳(15CM)")
                        } else if (shengcraft == "配弹力绳捆") {

                            arr.push(szColor + "配弹力绳(" + Math.ceil(data[0].count * 20 / 5000) + "捆)")
                            shengku = true;
                        }
                        arr.push($('input[name="kind2Value"]:checked').val());
                    } else if ($('input[name="kindValue"]:checked').val() == "6") {
                        craftQie = ""
                        var size1 = $(".size1").val();
                        size = $("#diySize").val();
                        if ((size.split("*")[0] < 3 || size.split("*")[1] < 3)) {
                            layer.msg("[ 服装吊牌600克铜版纸 ] 尺寸小于 3cm 请单独报价", {offset: ['300px', '300px']}, function () {
                            });
                            return false;
                        }
                        if (size1) {
                            if ((size1.split("*")[0] < 3 || size1.split("*")[1] < 3)) {
                                layer.msg("[ 服装吊牌600克铜版纸 ] 尺寸小于 3cm 请单独报价", {offset: ['300px', '300px']}, function () {
                                });
                                return false;
                            }
                            size = size + '厘米，' + size1
                        }
                        number = $("#numberTag").val();
                        arr = []
                        //arr = $('input[name="kind2Value"]:checked').val();
                        // arr.push("双面哑膜");
                        let shengcraft = $("input[name='craftSheng']:checked").val();
                        let szColor = $(".craftSheng select option:selected").val();
                        if (shengcraft == "配弹力绳") {
                            arr.push(szColor + "配弹力绳(15CM)")
                        } else if (shengcraft == "配弹力绳捆") {
                            arr.push(szColor + "配弹力绳(" + Math.ceil(data[0].count * 20 / 5000) + "捆)")
                            shengku = true;
                        }
                        arr.push($('input[name="kind2Value"]:checked').val());
                    } else if ($('input[name="kindValue"]:checked').val() == "3") { //  && craftQie == "异形模切"
                        var size2 = $(".size2").val();
                        size = $("#size").val();
                        if (size2) {
                            size = size + '厘米，' + size2
                        }
                        $("input:checkbox[name='craft']:checked").each(function (i) {
                            if (!$(this).is(':disabled')) {
                                if ($(this).val() != "双面覆哑膜") {
                                    let szColor = $(".tscolor select option:selected").val();
                                    if ($(this).val() == "弹力绳") {
                                        arr.push(szColor + "配弹力绳（15cm）");
                                    } else if ($(this).val() == "弹力绳捆") {
                                        arr.push(szColor + "配弹力绳(" + Math.ceil(data[0].count * 20 / 5000) + "捆)");
                                        shengku = true;
                                    } else if ($(this).val() == "打孔") {
                                        arr.push($(this).val() + $(".wkong option:selected").val());
                                    } else if ($(this).val() == "抠图") {
                                        return;
                                    } else {
                                        arr.push($(this).val());

                                    }
                                }
                            }
                        });
                    }
                    if (craftQie == "异形模切") {
                        craftQie = "不限形状";
                    }

                    var span_result = '服装吊牌 - ' + kindValueData[kindValue] + ' - ' + size + '厘米\n';
                    if (stickerKind == "常规") {
                        let shengz = $(".shengz:checked").length;
                        if (shengz == 1) {
                            let select = $(".scolor select option:selected").val();
                            let index = arr.findIndex((e) => {
                                return e == "绳子"
                            });
                            if (index >= 0) {
                                arr[index] = select;
                            }
                        }
                        if (craftAotu == null) {
                            span_result += "工艺： " + craftQie + ', ' + arr + "\n";
                        } else {
                            span_result += "工艺： " + craftQie + ', ' + arr + "," + craftAotu + "\n";
                        }
                    }
                    if (kindValue == 3) {
                        if (number > 1) {
                            for (let i = 0; i < data.length; i++) {
                                let price_text = "";

                                if (shengku) {
                                    price_text = "," + Math.ceil(data[i].count * 20 / 5000) + "捆";
                                }

                                span_result += number + '款 各' + data[i].count + "张，共" + data[i].price + "元" + price_text + '\n'
                                data[i].number = number;
                            }
                        } else {
                            for (let i = 0; i < data.length; i++) {
                                let price_text = "";

                                if (shengku) {
                                    price_text = "," + Math.ceil(data[i].count * 20 / 5000) + "捆";
                                }
                                span_result += number + '款 各' + data[i].count + "张，共" + data[i].price + "元" + price_text + '\n'
                                data[i].number = number;
                            }
                        }
                        span_result += '免费设计，全国包邮（偏远地区除外）\n'
                        if (window.parent.system_isGai) {
                            span_result += "\n亲 现在下单可以参加淘宝活动8.5折折扣哦!"
                        }
                        // if (!craftSheng) {
                        //     span_result += '送通用吊绳'
                        // } else {
                        //     span_result += '配' + craftSheng;
                        // }
                    } else {
                        if (number > 1) {

                            for (let i = 0; i < data.length; i++) {

                                let price_text = "";

                                if (shengku) {
                                    price_text = "," + Math.ceil(data[i].count * 20 / 5000) + "捆";
                                }
                                span_result += number + '款 各' + data[i].count + "张，共" + data[i].price + "元" + price_text + '\n'
                                data[i].number = number;
                            }
                        } else {

                            for (let i = 0; i < data.length; i++) {
                                let price_text = "";

                                if (shengku) {
                                    price_text = "," + Math.ceil(data[i].count * 20 / 5000) + "捆";
                                }
                                span_result += number + '款 ' + data[i].count + "张，共" + data[i].price + "元" + price_text + '\n'
                                data[i].number = number;
                            }
                        }
                        // if (!craftSheng) {
                        //     span_result += '配送普通吊绳'
                        // } else {
                        //     span_result += '配棉绳'
                        // }
                        span_result += "\n9*5.4CM以内 （不限形状）\n";
                        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($("#proTypeValue").val(), 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>