@{
    ViewBag.Title = "SeachInventory";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
<link href="~/Content/js/dialog/dialog.css" rel="stylesheet" />
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script src="~/Content/js/select2/select2.min.js"></script>
<script>
    var Code = $.request("Code");
    var InvName = decodeURI($.request("InvName"));
    var WHCode = $.request("WHCode");
    var ExtensionID = $.request("ExtensionID");
    var InvCode = $.request("InvCode");
    var Qty = $.request("Qty");
    
    $(function () {
        debugger;
        if (!!Code) {
            $("#txtInvCode").val(InvCode);
            $("#txtInvName").val(InvName);
            //$("#txtBatchCode").val(ExtensionID);
            $("#txtWHCode").val(WHCode);
        }
        Init();
    });
    function Init() {
        document.getElementById("gridPanel").innerHTML = ' <table id="gridList"></table>   ';//重置grid
        //var LotNo = $("#txt_LotNo").val();
        $("#gridList").dataGrid({
            url: "/WMS/ICSDisassemblyDoc/GetLotNoByKit?InvCode=" + InvCode + "&WHCode=" + WHCode + "&ExtensionID=" + ExtensionID + "&" + Math.random(),
            height: $(window).height() - 20,
            width: $(window).width() - 300,
            colModel: [
        { label: '主键', name: 'ID', hidden: true, key: true },
        { label: '仓库', name: 'WarehouseCode', width: 100, align: 'left' },
        { label: '库位', name: 'LocationCode', width: 100, align: 'left' },
        { label: '条码', name: 'LotNo', width: 100, align: 'left' },
        { label: '料品编码', name: 'InvCode', width: 100, align: 'left' },
        { label: '物料描述', name: 'InvName', width: 100, align: 'left' },
        { label: '辅助描述', name: 'InvDesc', width: 100, align: 'left' },
        { label: '规格型号', name: 'InvStd', width: 100, align: 'left' },
        { label: '单位', name: 'InvUnit', width: 100, align: 'left' },
        { label: '总数量', name: 'Quantity', width: 100, align: 'left' },
        { label: '辅计量数量', name: 'Amount', width: 100, align: 'left' },
        
            ],
            pager: "#gridPager",
            sortorder: "desc",
            sortname: 'LotNO',
            viewrecords: true,
            multiselect: true,
            gridComplete: function () {
            }
        })
    };



    function submitForm() {
        debugger;
        var rows = $("#gridList").jqGrid('getGridParam', 'selarrrow');
        if (rows.length <= 0) {
            $.modalAlertNew("WMS00077");
            return;
        }
        var count = 0;
        var Parameter = [];
        for (var i = 0; i < rows.length; i++) {
            var rowData = $("#gridList").jqGrid('getRowData', rows[i]);
            var obj = {
                WHCode: rowData.WarehouseCode,//仓库
                LocationCode: rowData.LocationCode,//库位
                LotNo: rowData.LotNo,//条码
                InvCode: rowData.InvCode,//料品
                Quantity: rowData.Quantity,//数量
            }
            count += Number(rowData.Quantity);
            Parameter.push(obj);
        }
        if (count != Qty) {
            $.modalAlertNew("WMS00078");
            return;
        }
        $.modalConfirm("确定保存吗?", function (r) {
            if (r) {
                $.submitForm({
                    url: "/WMS/ICSDisassemblyDoc/CreateLogByKit?Code=" + Code + "&" + Math.random(),
                    param: { Parameter: JSON.stringify(Parameter)},
                    success: function () {
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                    }
                })
            }
        });
    };



    function Close() {
        $.modalClose();
    }




</script>

<div style="margin-right: 20px;">
    <table class="form">
        <thead>套件信息</thead>
        <tr>
            <th class="formTitle">套装料品编码:</th>
            <td class="formValue">
                <input id="txtInvCode" type="text" disabled="disabled" class="form-control"  autocomplete="off" />
            </td>
            <th class="formTitle">套装物料描述:</th>
            <td class="formValue">
                <input id="txtInvName" type="text" disabled="disabled" class="form-control"  autocomplete="off" />
            </td>
            
            @*<th class="formTitle">批号:</th>
            <td class="formValue">
                <input id="txtBatchCode" type="text" disabled="disabled" class="form-control"  autocomplete="off" />
            </td>*@
           
            <th class="formTitle">仓库:</th>
            <td class="formValue">
                <input id="txtWHCode" type="text" disabled="disabled" class="form-control"  autocomplete="off" />
            </td>
        </tr>

    </table>


</div>

<div class="gridPanel" id="gridPanel">
    <table id="gridList"></table>
    @*<div id="gridPager"></div>*@
</div>