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


<link href="~/Content/css/CommonReport/CommonReport.css" rel="stylesheet" />
<script src="~/Content/js/CommonReport/CommonReport.js"></script>
<link href="~/Content/css/bootstrap/bootstrap-select.css" rel="stylesheet" />
<script src="~/Content/js/bootstrap/bootstrap-select.min.js"></script>
<style>
    * {
        box-sizing: border-box;
    }
</style>
<script>
    debugger;
    //var Arguments = decodeURI($.request("Arguments"));
    //var Arguments = '{"name":"wust", "url":"www.wust.edu.cn", "age":120}';
    var ID = $.request("ID");
    var mold = $.request("mold");
    var Arguments = decodeURI($.request("Arguments"));
    $(function () {
        InitControl();
        $("#sel_LableType").val(mold).trigger("change");
        $("#sel_LableType").attr("disabled", "disabled");
        InitContro2();
        $("#sel_LableType").change(function () {
            InitContro2();
        });

    });

    //function GetTXT() {
    //    if (!!ID) {
    //        $.ajax({
    //            url: "/WMS/BasicSettings/GetLabelTXT?ID=" + ID + "&" + Math.random(),
    //            dataType: "json",
    //            async: false,
    //            success: function (data) {
    //                debugger;
    //                $("#txtLableCode").val(data.rows[0].LableCode);
    //                $("#txtLableName").val(data.rows[0].LableName);
    //                $("#sel_LableType").val(data.rows[0].LableType).trigger("change");
    //                $("#sel_LableSourceID").val(data.rows[0].LableSourceID).trigger("change");
    //            }
    //        });
    //    }
    //};


    function InitControl() {
        var $LableType = $("#sel_LableType");
        $LableType.select2({
            allowClear: true,
            escapeMarkup: function (m) {
                return m;
            }
        });
        $.ajax({
            url: "/WMS/Print/GetLableType" + "?" + Math.random(),
            dataType: "json",
            async: false,
            success: function (data) {
                $.each(data, function (index, item) {
                    $LableType.append("<option value='" + item.F_ItemCode + "'>&nbsp;" + item.F_ItemName + "</option>");
                });
            }
        });
    }

    function InitContro2() {
        $("#Sys_LablesID").empty();
        var LableType= $("#sel_LableType").val();
        var $Sys_LablesID = $("#Sys_LablesID");
        $Sys_LablesID.select2({
            allowClear: true,
            escapeMarkup: function (m) {
                return m;
            }
        });
        $.ajax({
            url: "/WMS/Print/GetSys_LablesID?LableType=" + LableType + "&" + Math.random(),
            dataType: "json",
            async: false,
            success: function (data) {
                $.each(data, function (index, item) {
                    $Sys_LablesID.append("<option value='" + item.ID + "'>&nbsp;" + item.LableName + "</option>");
                });
            }
        });
    }



    function submitForm() {
      
        var strPrintData;
        var bIsInstallPrintControl;
        var strPrintControlCookie;
        var objArr = {
            Sys_LablesID: $("#Sys_LablesID").val(),
        };
       
        $.ajax({
            url: "/WMS/Print/PrintItemLot" + "?" + Math.random(),
            type: "post",
            data: { keyValue: JSON.stringify(objArr), Parameter: JSON.stringify(Arguments) },
            dataType: "json",
            async: false,
            success: function (data) {
                strPrintData = data.strPrintData_1;
                bIsInstallPrintControl = data.bIsInstallPrintControl_1;
                strPrintControlCookie = data.strPrintControlCookie_1;
            }
        });
        if (strPrintData != '') {
            var test = "ChuLinPrint:" + strPrintData;
            $("#ifrm")[0].src = "ChuLinPrint:" + strPrintData;
        }
        if (bIsInstallPrintControl == 'False') {
            if (confirm("检测到打印控件未安装,您是否下载安装?")) {
                $("#downPrintControl").click();
            }
        }
        if (bIsInstallPrintControl == 'True') {
            var strPrintControlCookie = strPrintControlCookie;
            if (strPrintControlCookie != '') { //延时3秒后再次检测打印控件是否安装
                setTimeout("checkPrintControlInstall()", 8000);
                function checkPrintControlInstall() {
                    $.ajax({
                        url: "/WMS/WMSCreateItemLot/IsCheckInstall?checkInstall=" + strPrintControlCookie,
                        dataType: "json",
                        async: false,
                        success: function (strResult) {
                            if (strResult.indexOf("PrintControlInstall") == -1) {
                                if (confirm("检测到打印控件未安装,您是否下载安装?")) {
                                    $("#downPrintControl").click();
                                }
                            }
                        }
                    });
                }
            }
        }
     

    }








</script>
<iframe id="ifrm" src="" width="0" height="0"></iframe>
<div class="btn-group" style="display:block;padding-left:2px;">
    <a class="btn btn-primary" id="downPrintControl" href="~/PrintActivex.exe" style="display:none">点击下载打印组件</a>
</div>
<form id="form1">
    <div class="widget-body">

        <div style="padding-top: 5px;  ">
            <div class="step-content" id="wizard-steps" style="border-left: none; border-bottom: none; border-right: none;">
                <div class="step-pane active" id="step-1" style="padding-left: 5px; padding-top: 20px; margin-right: 20px;">

                    <table class="form">
                        <tr>
                            <th class="formTitle">标签类型: </th>
                            <td class="formValue">
                                <select id="sel_LableType" name="sel_LableType" class="form-control select2" style="width: 230px" placeholder="请选择标签类型..."></select>
                                <input type="hidden" id="hidetext" />
                            </td>
                        </tr>
                        <tr>
                            <th class="formTitle">打印模板:</th>
                            <td class="formValue">
                                <select id="Sys_LablesID" name="Sys_LablesID" class="form-control select2" style="width: 230px" placeholder="请选择标签类型..."></select>
                                <input type="hidden" id="hidetext" />
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
</form>