@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<style>
    #ISO {
        width: 10px;
    }
</style>
<link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
<script src="~/Content/js/select2/select2.min.js"></script>


<script>
    debugger;

    var ID = $.request("ID");
    var InvCode = $.request("InvCode");
    var InvName = decodeURI($.request("InvName"));
    var BCGroupID = $.request("BCGroupID");
    var BRGroupID = $.request("BRGroupID");
    var Enable = $.request("Enable");
    $(function () {
        debugger;
        InitControl();
        $("#sel_InvCode").val([InvCode]).trigger("change");
        InitControl2();
        $("#sel_BCGroupID").val([BCGroupID]).trigger("change");
        InitControl3();
        $("#sel_BRGroupID").val([BRGroupID]).trigger("change");
        if (Enable == '1') {
            $("#StatusYes").prop("checked", true);
        } else {
            $("#StatusNo").prop("checked", true);
        }
    });

    //物料
    function InitControl() {
        debugger;
        var $InvCode = $("#sel_InvCode");
        $InvCode.select2({
            allowClear: true,
            escapeMarkup: function (m) {
                return m;
            }
        });
        $.ajax({
            url: "/WMS/BasicSettings/GetInvCode" + "?" + Math.random(),
            dataType: "json",
            async: false,
            success: function (data) {
                $.each(data, function (index, item) {
                    $InvCode.append("<option value='" + item.InvCode + "'>" + item.InvName + "</option>");
                });
            }
        });
    }

    //不良代码
    function InitControl2() {
        debugger;
        var $BCGroupID = $("#sel_BCGroupID");
        $BCGroupID.select2({
            allowClear: true,
            escapeMarkup: function (m) {
                return m;
            }
        });
        $.ajax({
            url: "/WMS/BasicSettings/GetBCGroup" + "?" + Math.random(),
            dataType: "json",
            async: false,
            success: function (data) {
                $.each(data, function (index, item) {
                    $BCGroupID.append("<option value='" + item.ID + "'>" + item.BCGDesc + "</option>");
                });
            }
        });
    }

    //不良原因
    function InitControl3() {
        debugger;
        var $BRGroupID = $("#sel_BRGroupID");
        $BRGroupID.select2({
            allowClear: true,
            escapeMarkup: function (m) {
                return m;
            }
        });
        $.ajax({
            url: "/WMS/BasicSettings/BRGroupID" + "?" + Math.random(),
            dataType: "json",
            async: false,
            success: function (data) {
                $.each(data, function (index, item) {
                    $BRGroupID.append("<option value='" + item.ID + "'>" + item.BRGDesc + "</option>");
                });
            }
        });
    }



    function submitForm() {
        debugger;
        var BCGroupID = $("#sel_BCGroupID").val();
        var BRGroupID = $("#sel_BRGroupID").val();
        var Enable = $('input[name="State"]:checked').val();
        if (BCGroupID == "") {
            $.modalAlertNew("WMS00035");
        }
        if (BRGroupID == "") {
            $.modalAlertNew("WMS00036");
        }
        var objArr = {
            ID:ID,
            BCGroupID: BCGroupID,
            BRGroupID:BRGroupID,
            Enable: Enable
        }
       
            $.submitForm({
                url: "/WMS/BasicSettings/UpdateInventoryBadGroup" + "?" + Math.random(),
                param: { keyValue: JSON.stringify(objArr) },
                success: function () {
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
            })
      


    }


</script>

<form id="form1">
    <div style="padding-top: 55px; margin-right: 130px;">
        <table class="form">
            <tr>
                <th class="formTitle">料品编码:</th>
                <td style="width:100px">
                    <select id="sel_InvCode" name="sel_InvCode" class="form-control select2" style="width: 500px" placeholder="料品编码"></select>
                    <input type="hidden" id="hidetext" />
                </td>
            </tr>
            <tr style="height:20px"></tr>
            <tr>
                <th class="formTitle">不良代码:&nbsp;</th>
                <td style="width:100px">
                    <select id="sel_BCGroupID" name="sel_BCGroupID" class="form-control select2" style="width: 500px" placeholder="料品编码"></select>
                    <input type="hidden" id="hidetext" />
                </td>
            </tr>
            <tr style="height:20px"></tr>
            <tr>
                <th class="formTitle">不良原因:&nbsp;</th>
                <td style="width:100px">
                    <select id="sel_BRGroupID" name="sel_BRGroupID" class="form-control select2" style="width: 500px" placeholder="料品编码"></select>
                    <input type="hidden" id="hidetext" />
                </td>
            </tr>
            <tr style="height:20px"></tr>
            <tr>
                <th class="formTitle">是否启用:&nbsp;</th>
                <td>
                    <div class="input-group" id="changechaeckbox">
                        <input type="radio" name="State" value="1" id="StatusYes" style="width:30px" /><label for="cb-NoQuotedPrice">是</label>
                        <input type="radio" name="State" value="0" id="StatusNo" style="width:30px" /><label for="cb-QuotedPrice">否</label>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</form>