@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<style>
    .form {
        margin: 25px -30px;
    }
</style>



<script>

    var WorkPoints = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
    var User = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
    var Times = new Date();
    var Time = formatDate("YYYY-mm-dd HH:MM:SS", Times);
    $(function () {
        $("#minPackQty").keyup(function () {
            $(this).val($(this).val().replace(/[^0-9.]/g, ''));
        }).bind("paste", function () {  //CTR+V事件处理
            $(this).val($(this).val().replace(/[^0-9.]/g, ''));
        }).css("ime-mode", "disabled"); //CSS设置输入法不可用
        $("#thisCreateQty").keyup(function () {
            $(this).val($(this).val().replace(/[^0-9.]/g, ''));
        }).bind("paste", function () {  //CTR+V事件处理
            $(this).val($(this).val().replace(/[^0-9.]/g, ''));
        }).css("ime-mode", "disabled"); //CSS设置输入法不可用
        $("#cretePageCount").keyup(function () {
            $(this).val($(this).val().replace(/[^0-9.]/g, ''));
        }).bind("paste", function () {  //CTR+V事件处理
            $(this).val($(this).val().replace(/[^0-9.]/g, ''));
        }).css("ime-mode", "disabled"); //CSS设置输入法不可用

        $("#txtMUSER").val(User);
        $("#txtMTIME").val(Time);
        $("#txtMUSER").attr("disabled", "disabled");
        $("#txtMTIME").attr("disabled", "disabled");
        InitControl();
     
    });


    function formatDate(fomatType, date) {
        let ret;
        let valueDate = date;
        if (!date) valueDate = new Date()
        let opt = {
            "Y+": valueDate.getFullYear().toString(),        // 年
            "m+": (valueDate.getMonth() + 1).toString(),     // 月
            "d+": valueDate.getDate().toString(),            // 日
            "H+": valueDate.getHours().toString(),           // 时
            "M+": valueDate.getMinutes().toString(),         // 分
            "S+": valueDate.getSeconds().toString()          // 秒
        };
        for (let k in opt) {
            ret = new RegExp("(" + k + ")").exec(fomatType);
            if (ret) {
                fomatType = fomatType.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
            };
        };
        return fomatType;
    }




    function InitControl() {
        debugger;
        var $WHCode = $("#sel_WHCode");
        $WHCode.select2({
            allowClear: true,
            escapeMarkup: function (m) {
                return m;
            }
        });
        $.ajax({
            url: "/WMS/Blitem/GetWHCode?" + Math.random(),
            dataType: "json",
            async: false,
            success: function (data) {
                $.each(data, function (index, item) {
                    $WHCode.append("<option value='" + item.WarehouseCode + "'>" + item.WarehouseName + "</option>");
                });
            }
        });
    }

    function submitForm() {
        debugger;
        if (!$('#form1').formValid()) {
            return false;
        }
        var WHCode = $("#sel_WHCode").val();
        if (WHCode=='') {
            $.modalAlert("请选择仓库!");
            return;
        }
        var Details = [];
        var obj = {
            WHCode: WHCode,
           
        };
        Details.push(obj);

        var Header = {
            User: User,
            MTIME: Time,
            WorkPoint: WorkPoints,
            Detail: Details,
        }
        var Parameter = [];
        Parameter.push(Header);

        $.submitForm({
            url: "/WMS/Blitem/AddICSCheck?" + Math.random(),
            param: { Parameter: JSON.stringify(Parameter) },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }



</script>

<form id="form1">
    <div style="padding-top: 20px; margin-right: 20px;">
        <table class="form">
            <tr>
                <th class="formTitle">&nbsp;盘点仓库:</th>
                <td style="width:100px">
                    <select id="sel_WHCode" name="sel_WHCode" class="form-control select2" style="width: 500px" placeholder="料品条码"></select>
                    <input type="hidden" id="hidetext" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">维护人:</th>
                <td class="formValue">
                    <input id="txtMUSER" name="txtMUSER" type="text" class="form-control " />
                </td>
            </tr>
            <tr>
                <th class="formTitle">维护日期:</th>
                <td class="formValue">
                    <input id="txtMTIME" name="txtMTIME" type="text" class="form-control " />
                </td>
            </tr>
        </table>
    </div>
</form>