@{
    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;


    $(function () {
        debugger;

            InitControl();
            InitControl2();
            InitControl3();

        
    });

    //物料
    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 InvCode = $("#sel_InvCode").val();
        var BCGroupID = $("#sel_BCGroupID").val();
        var BRGroupID = $("#sel_BRGroupID").val();
        var Enable = $('input[name="State"]:checked').val();
        if (InvCode == "") {
            $.modalAlertNew("WMS00034");
        }
        if (BCGroupID == "") {
            $.modalAlertNew("WMS00035");
        }
        if (BRGroupID == "") {
            $.modalAlertNew("WMS00036");
        }
        var objArr = {
            InvCode: InvCode,
            BCGroupID: BCGroupID,
            BRGroupID:BRGroupID,
            Enable: Enable
        }
       
            $.submitForm({
                url: "/WMS/BasicSettings/InsertInventoryBadGroup" + "?" + 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">不良代码:</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">不良原因:</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">是否启用:</th>
                <td>
                    <div class="input-group" id="changechaeckbox">
                        <input type="radio" name="State" value="1" id="cb-StatusYes" style="width:30px" /><label for="cb-NoQuotedPrice">是</label>
                        <input type="radio" name="State" value="0" id="cb-StatusNo" style="width:30px" /><label for="cb-QuotedPrice">否</label>
                    </div>
                </td>
            </tr>
</table>
    </div>
</form>