@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<body>
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <table id="configurationTable" class="table table-bordered table-striped table-hover">
                    <tr>
                        <td colspan="2" style="text-align:right"><button id="btnSave" onclick="SaveSet()" class="btn btn-default"><i class="glyphicon glyphicon-saved"></i> 保 存</button></td>
                    </tr>
                 @*   <tr>
                        <td style="text-align: right">启用过账功能:</td>
                        <td>
                            <input type="radio" value="是" name="BillPosting">
                            是<input type="radio" value="否" name="BillPosting">
                            否
                        </td>
                    </tr>*@
                    <tr>
                        <td style="text-align: right">启用基本信息授权控制:</td>
                        <td>
                            <input type="radio" value="是" name="UserPower">
                            是<input type="radio" value="否" name="UserPower">
                            否
                        </td>
                    </tr>
                    <tr >
                        <td style="text-align: right">数量小数位:</td>
                        <td>
                            <input type="text" maxlength="1" onblur="this.value=this.value.replace(/[^0-6]/g,'')"  onkeyup="this.value=this.value.replace(/[^0-6]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-6]/g,'')" id="QtyPoint">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">单价小数位:</td>
                        <td>
                            <input type="text" maxlength="1" onblur="this.value=this.value.replace(/[^0-6]/g,'')"  onkeyup="this.value=this.value.replace(/[^0-6]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-6]/g,'')" id="PricePoint">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">折扣小数位:</td>
                        <td>
                            <input type="text" maxlength="1" onblur="this.value=this.value.replace(/[^0-6]/g,'')"  onkeyup="this.value=this.value.replace(/[^0-6]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-6]/g,'')" id="DiscountPoint">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">金额小数位:</td>
                        <td>
                            <input type="text" maxlength="1" onblur="this.value=this.value.replace(/[^0-6]/g,'')" onkeyup="this.value=this.value.replace(/[^0-6]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-6]/g,'')" id="TotalPoint">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">上传打印小票时所需图片:</td>
                        <td>
                            <form id="firstImgForm" name="formfirstImg" action="/WLTManage/UploadImageSeals" enctype="multipart/form-data" method="post" target="ajaxUploadUplodaFirstImg">
                                <div style="width:140px;height:28px;padding:0px;float:left" class="btn btn-default">
                                    <input onchange="FirstImg()" name="firstImg" type="file" id="FirstfileImg" style="position:relative;opacity:0;width:inherit;height:inherit;z-index:5;" />
                                    <div style="position:relative;width:inherit;height:inherit;margin-top:-40px;z-index:2;">
                                        <span class="glyphicon glyphicon-folder-open" style="line-height:45px;"> 选择上传图片</span>
                                    </div>
                                </div>
                                &nbsp;&nbsp; <span id="fileFirstimg" class="btn btn-default" style="float:left;" onclick="UploadFirstImg()">开始上传</span>
                                <iframe name="ajaxUploadUplodaFirstImg" hidden="hidden"></iframe>
                            </form>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right"></td>
                        <td>
                            <img id="firstimg" onclick="ClearfirtsImg()" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>

    <script type="text/javascript">
    //上传打印小票时所需图片预览
    function FirstImg() {
        $.ImgYulan(document.getElementById("FirstfileImg").files[0], "firstimg");
    }
    //去上传打印小票时所需图片
    function ClearfirtsImg() {
        var file = $("#FirstfileImg")
        file.after(file.clone().val(""));
        file.remove();
        $("#firstimg").removeAttr("src");
        $("#firstimg").removeAttr("title");
        $("#firstimg").removeAttr("width");
        $("#firstimg").removeAttr("height");

    }
    //上传打印小票时所需图片
    function UploadFirstImg() {
        if (document.getElementById("FirstfileImg").files.length < 1) {
            layer.msg("请选择图片", { icon: 2, time: 2000 });
            return;
        }
        $("#firstImgForm").submit();
    }
    $(function () {
        var data = parent.$('#configurationTable').bootstrapTable('getData');
        for (var i = 0; i < data.length; i++) {
            //if (data[i]["TypeName"] == "BillPosting") {    //启用过账功能  BillPosting
            //    $("input[name='BillPosting'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            //}
            if (data[i]["TypeName"] == "UserPower") {    //启用基本信息授权控制  UserPower
                $("input[name='UserPower'][value='" + data[i]["TypeValues"] + "']").attr("checked", true);
            }
            if (data[i]["TypeName"] == "UploadImageSeals") {//上传打印小票时所需图片

            } if (data[i]["TypeName"] == "QtyPoint") {//数量小数位
                $("#QtyPoint").val(data[i]["TypeValues"]);
            }
            if (data[i]["TypeName"] == "PricePoint") {//单价小数位
                $("#PricePoint").val(data[i]["TypeValues"]);
            }
            if (data[i]["TypeName"] == "DiscountPoint") {//折扣小数位
                $("#DiscountPoint").val(data[i]["TypeValues"]);
            }
            if (data[i]["TypeName"] == "TotalPoint") {//金额小数位
                $("#TotalPoint").val(data[i]["TypeValues"]);
            }
        }
    });
    function SaveSet() {
        var par = {
            UserPower: $("input[name='UserPower']:checked").val(),//启用基本信息授权控制  UserPower
            //BillPosting: $("input[name='BillPosting']:checked").val()//启用过账功能
            QtyPoint: $("#QtyPoint").val(),//数量小数位
            PricePoint: $("#PricePoint").val(),//单价小数位
            DiscountPoint: $("#DiscountPoint").val(),//折扣小数位
            TotalPoint: $("#TotalPoint").val()//金额小数位
        }
        $.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>