@{
    ViewBag.Title = "前台全局配置设置";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<body>
    <div class="wrapper wrapper-content">
        <div class="ibox-content ">
            <div class="form-horizontal m-t">
                <table id="configurationTable" class="table table-bordered table-striped table-hover">
                    <tr>
                        <td>开单时经手人读取客户默认经手人:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="GetBTypeETypeID">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="GetBTypeETypeID">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>收款金额默认为单据金额:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="PayMoneyisBillTota">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="PayMoneyisBillTota">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>录单快速进入开单界面:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="ClickToNewBill">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="ClickToNewBill">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>录单时相同商品提示不显示:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="samehint">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="samehint">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>验货扫描条码商品重复自动取第一个:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="checksameFrist">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="checksameFrist">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>验货源单在线选取:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="billcheckonline">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="billcheckonline">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>数量单价等默认不弹出软键盘:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="keyboardshow">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="keyboardshow">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>选择商品时，立即录入数量:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="countprice">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="countprice">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>添加商品保存后继续选择:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="keepselect">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="keepselect">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>添加商品后以倒序展示:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="orderbydesc">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="orderbydesc">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>开单默认数量为1:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="billcount">是
                                </label>
                            </div>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="否" name="billcount">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>获取即时库存:</td>
                        <td>
                            <div class="radio i-checks inline" name="immediatecount">
                                <label>
                                    <input type="radio" value="是" name="immediatecount">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" name="immediatecount">
                                <label>
                                    <input type="radio" value="否" name="immediatecount">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>业务开单时显示虚拟库存数量:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input id="virtualstock1" type="radio" value="是" name="virtualstock">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="virtualstock">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    @*<tr>
                        <td>开单选择商品时,库存为0不显示:</td>
                        <td>
                            <div class="radio i-checks inline">
                                <label>
                                    <input type="radio" value="是" name="qtyzeronotshow">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="qtyzeronotshow">否
                                </label>
                            </div>
                        </td>
                    </tr>*@
                    <tr>
                        <td>获取即时价格跟踪:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="是" name="immediateprice">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="immediateprice"> 否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>开提交后取价格跟踪:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="是" name="SubmitGetPriceTrack">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="SubmitGetPriceTrack">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>扫描条码后，立即编辑商品:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="是" name="ScanPTypeEdit">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="ScanPTypeEdit">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>扫描条码后，快速输入数量:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" id="ID1" value="是" name="ScanQuickQty">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" id="ID2" value="否" name="ScanQuickQty">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>车载库存只计算已提交单据:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="是" name="CarStockSubmit">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="CarStockSubmit">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>检索条码时至少输入条码的后几位:</td>
                        <td>
                            <input type="text" id="lastnum" style="width: 400px">
                        </td>
                    </tr>
                    <tr>
                        <td>默认开单价:</td>
                        <td>
                            <select id="DefPriceID" style="width: 200px"></select>
                        </td>
                    </tr>
                    <tr>
                        <td>看图开单默认单据类型:</td>
                        <td>
                            <select id="picturebilltype" style="width: 200px">
                                <option Value="销售订单">销售订单</option>
                                <option Value="销售单">销售单</option>
                                <option Value="无">无</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>看图开单横屏应用:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="是" onclick="Pictq()" name="picturebilllande">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" onclick="PictT()" name="picturebilllande">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>看图开单横屏后每行图片数量:</td>
                        <td>
                            <input type="text" id="picturebilllinenums" style="width: 400px">
                        </td>
                    </tr>
                    <tr>
                        <td>开单默认大单位:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="是" name="bigdanwei">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="bigdanwei">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>开单商品切换单位,单价按换算率转换:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="是" name="qiehuanunit">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="qiehuanunit">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>启用客户销售价格类型跟踪:</td>
                        <td>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="是" name="btypeprice">是
                                </label>
                            </div>
                            <div class="radio i-checks inline" id="virtualstock2">
                                <label>
                                    <input type="radio" value="否" name="btypeprice">否
                                </label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td style="text-align:left">
                            <span id="btnSave" onclick="SaveSet()" class="btn button-glow btn-default"><i class="glyphicon glyphicon-saved"></i> 保 存</span>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <script type="text/javascript">
    $(function () {
        parent.$("body").css("overflow", "hidden");
        var data = parent.$('#configurationTable').bootstrapTable('getData');
        $.ajax({
            url: "../WLTManage/GetDefPriceID",
            dataType: "html",
            type: "post",
            async: false,
            success: function (data) {
                $("#DefPriceID").append(data);
            }
        });
        for (var i = 0; i < data.length; i++) {
            if (data[i]["TypeName"] == "GetBTypeETypeID") {     //开单时经手人读取客户默认经手人
                $("input[name='GetBTypeETypeID'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "ClickToNewBill") {   //录单快速进入开单界面
                $("input[name='ClickToNewBill'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "samehint") { //录单时相同商品提示不显示
                $("input[name='samehint'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "checksameFrist") {  //验货扫描条码商品重复自动取第一个
                $("input[name='checksameFrist'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "billcheckonline") { //验货源单在线选取
                $("input[name='billcheckonline'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "keyboardshow") { //数量单价等默认不弹出软键盘
                $("input[name='keyboardshow'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "countprice") { //选择商品时，立即录入数量
                $("input[name='countprice'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "keepselect") { //添加商品保存后继续选择
                $("input[name='keepselect'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "orderbydesc") { //添加商品后以倒序展示
                $("input[name='orderbydesc'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "billcount") { //开单商品默认为1
                $("input[name='billcount'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "immediatecount") { //获取即时库存
                $("input[name='immediatecount'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "virtualstock") { //业务开单时显示虚拟库存数量
                $("input[name='virtualstock'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            //if (data[i]["TypeName"] == "qtyzeronotshow") { //开单选择商品时,库存为0不显示
            //    $("input[name='qtyzeronotshow'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            //}
            if (data[i]["TypeName"] == "immediateprice") { //获取即时价格跟踪
                $("input[name='immediateprice'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "ScanPTypeEdit") { //扫描条码后，立即编辑商品
                $("input[name='ScanPTypeEdit'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }

            if (data[i]["TypeName"] == "ScanQuickQty") { //扫描后快速输入数量
                $("input[name='ScanQuickQty'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "SubmitGetPriceTrack") { //开提交后取价格跟踪
                $("input[name='SubmitGetPriceTrack'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }

            if (data[i]["TypeName"] == "CarStockSubmit") { //车载库存只计算已提交单据
                $("input[name='CarStockSubmit'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "lastnum") { //检索条码时至少输入条码的后几位
                $("#lastnum").val(data[i]["TypeValues"]);
            }
            if (data[i]["TypeName"] == "DefPriceID") { //默认开单价
                if (data[i]["TypeValues"]) {
                    $("#DefPriceID").find("option[text=" + data[i]["TypeValues"] + "]").prop("selected", true);
                }
            }
            if (data[i]["TypeName"] == "picturebilltype") { //看图开单默认单据类型
                $("#picturebilltype").val(data[i]["TypeValues"]);
                //$("#picturebilltype").find("option[text=" + data[i]["TypeValues"] + "]").prop("selected", true);
            }
            if (data[i]["TypeName"] == "picturebilllande") { //看图开单横屏应用
                $("input[name='picturebilllande'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
                //if (data[i]["TypeValues"] == "否") {
                //    $("#picturebilllinenums").attr("disabled", "true");
                //}
            }
            if (data[i]["TypeName"] == "picturebilllinenums") { //看图开单横屏后每行图片数量
                $("#picturebilllinenums").val(data[i]["TypeValues"]);
            }
            if (data[i]["TypeName"] == "bigdanwei") { //开单默认大单位
                $("input[name='bigdanwei'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "qiehuanunit") { //开单商品切换单位,单价按换算率转换
                $("input[name='qiehuanunit'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "btypeprice") { //启用客户销售价格类型跟踪
                $("input[name='btypeprice'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "PayMoneyisBillTota") {//收款金额默认为单据金额
                $("input[name='PayMoneyisBillTota'][value='" + data[i]["TypeValues"] + "']").attr("checked", true)
            }
        }
        $(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });
     
    });
    function SaveSet() {
        //检索条码时至少输入条码的后几位
        var reg = /^[0-9]*[1-9][0-9]*$/;
        if ($("#lastnum").val().trim() && !reg.test($("#lastnum").val())) {
            //alert($.GetXaddress(document.getElementById("lastnum")));
            $.LeversScroll(window, document.getElementById("lastnum"));
            layer.tips('只能为正整数字或者为空', '#lastnum', {
                shift: 0,
                tips: [1, '#c00']
            });
            return;
        }
        if ($("input[name='picturebilllande']:checked").val() == "是" && $("#picturebilllinenums").val().trim() && !reg.test($("#picturebilllinenums").val())) {
            //alert($.GetXaddress(document.getElementById("lastnum")));
            $.LeversScroll(window, document.getElementById("picturebilllinenums"));
            layer.tips('只能为正整数字或者为空', '#picturebilllinenums', {
                shift: 0,
                tips: [1, '#c00']
            });
            return;
        }
        var par = {
            GetBTypeETypeID: $("input[name='GetBTypeETypeID']:checked").val(),//开单时经手人读取客户默认经手人
            ClickToNewBill: $("input[name='ClickToNewBill']:checked").val(), //录单快速进入开单界面
            samehint: $("input[name='samehint']:checked").val(), //录单时相同商品提示不显示
            checksameFrist: $("input[name='checksameFrist']:checked").val(),//验货扫描条码商品重复自动取第一个
            billcheckonline: $("input[name='billcheckonline']:checked").val(),//验货源单在线选取
            keyboardshow: $("input[name='keyboardshow']:checked").val(),//数量单价等默认不弹出软键盘
            countprice: $("input[name='countprice']:checked").val(), //选择商品时，立即录入数量
            keepselect: $("input[name='keepselect']:checked").val(), //添加商品保存后继续选择
            orderbydesc: $("input[name='orderbydesc']:checked").val(), //添加商品后以倒序展示
            billcount: $("input[name='billcount']:checked").val(),//开单商品默认为1
            immediatecount: $("input[name='immediatecount']:checked").val(), //获取即时库存
            virtualstock: $("input[name='virtualstock']:checked").val(), //业务开单时显示虚拟库存数量
            //qtyzeronotshow: $("input[name='qtyzeronotshow']:checked").val(),//开单选择商品时,库存为0不显示
            immediateprice: $("input[name='immediateprice']:checked").val(),//获取即时价格跟踪
            ScanPTypeEdit: $("input[name='ScanPTypeEdit']:checked").val(),//扫描条码后，立即编辑商品
            ScanQuickQty: $("input[name='ScanQuickQty']:checked").val(),//扫描后快速输入数量
            SubmitGetPriceTrack: $("input[name='SubmitGetPriceTrack']:checked").val(),//开提交后取价格跟踪
            CarStockSubmit: $("input[name='CarStockSubmit']:checked").val(), //车载库存只计算已提交单据
            lastnum: $("#lastnum").val(), //检索条码时至少输入条码的后几位
            DefPriceID: $("#DefPriceID").val(), //默认开单价
            picturebilltype: $("#picturebilltype").val(), //看图开单默认单据类型
            picturebilllande: $("input[name='picturebilllande']:checked").val(),//看图开单横屏应用
            PayMoneyisBillTota: $("input[name='PayMoneyisBillTota']:checked").val(), //收款金额默认为单据金额
            bigdanwei: $("input[name='bigdanwei']:checked").val(), //开单默认大单位
            qiehuanunit: $("input[name='qiehuanunit']:checked").val(), //开单商品切换单位,单价按换算率转换
            btypeprice: $("input[name='btypeprice']:checked").val(),//启用客户销售价格类型跟踪
        }
        if ($("input[name='picturebilllande']:checked").val()=="是") {
            par.picturebilllinenums = $("#picturebilllinenums").val();// 看图开单横屏后每行图片数量
        }
        var msg = "";
        if (par.immediatecount == par.virtualstock && (par.immediatecount != "否" && par.virtualstock != "否")) {
            msg += "<span style='color:red'>获取即时库存</span>与<span style='color:red'>业务开单时显示虚拟库存数量;</span><br/>";
        }
        if (par.immediateprice == par.SubmitGetPriceTrack && (par.SubmitGetPriceTrack != "否" && par.immediateprice != "否")) {
            msg += "<span style='color:red'>获取即时价格跟踪</span>与<span style='color:red'>开提交后取价格跟踪;</span><br/>";
        }
        if (par.ScanPTypeEdit == par.ScanQuickQty && (par.ScanQuickQty != "否" && par.ScanPTypeEdit != "否")) {
            msg += "<span style='color:red'>扫描条码后，立即编辑商品</span>与<span style='color:red'>扫描条码后，快速输入数量;</span><br/>";
        }
        if (msg.length > 0) {
            msg += "状态不能设置一致";
            layer.alert(msg, { area: ['400px'] });
            return;
        }
        $.ajax({
            url: "../WLTManage/SaveAlertUserConfiguration",
            dataType: "text",
            data: JSON.stringify(par),
            type: "post",
            success: function (data) {
                parent.$('#configurationTable').bootstrapTable('refresh');
                parent.layer.msg("保存成功", { icon: 1, time: 2000 });
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            }, error: function () {
                layer.msg("连接超时！");
            }
        });
    }
    </script>
</body>
