<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <base href="#springUrl('/assets/adminlte/')"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>工作台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">

    <!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="plugins/select2/select2.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <!--validate css-->
    <link rel="stylesheet" href="plugins/jquery-validation/css/validate.css">
    <!-- ztree css -->
    <link rel="stylesheet"
          href="plugins/ztree/css/metroStyle/metroStyle.css" type="text/css"/>
    <!--fileinput css-->
    <link rel="stylesheet" href="plugins/bootstrap-fileinput/bootstrap-fileinput.css">
    <link rel="stylesheet" href="common/css/uePicPicker.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<!-- END HEAD -->
<body class="hold-transition skin-blue sidebar-mini">

<div class="wrapper">
    <div class="content-wrapper" style="margin-left:0;">

        <section class="content-header">
            <h1>
                二维码管理
                <small>二维码</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>首页</a></li>
                <li><a class="active">二维码</a></li>
            </ol>
        </section>


        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <!-- general form elements disabled -->
                    <div class="box box-primary">
                        <form role="form" id="myForm">
                            <input name="id" value="$!{data.id}" hidden="true"/>
                            <input name="type" id="type" value="$!{data.type}" hidden="true"/>
                            <input name="qrcodeUri" id="qrcodeUri" value="$!{data.ticket}" hidden="true"/>
                            <div class="box-body">
                                <div class="col-md-8">
                                    <div class="row">
                                        <div class="form-group form-md-line-input col-md-6">
                                            <label><font color="blue">数量</font>(输入多少数量就生成多少个二维码，推荐每次100以内)</label>
                                            <input type="text"
                                                   class="form-control" name="qty"
                                                   id="qty"
                                                   maxlength="20" placeholder="需要批量生成的数量"
                                                   value=""
                                            >
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="form-group form-md-line-input col-md-6">
                                            <label>二维码类别</label>
                                            <select class="form-control select2" name="typeselect"
                                                    id="typeselect" style="width: 100%;">
                                                <option value="1">药师二维码</option>
                                                <option value="2">客服二维码</option>
                                                <option value="3">医生二维码</option>
                                                <option value="4">组织二维码</option>
                                            </select>

                                        </div>
                                    </div>

                                    <!--<div class="form-group form-md-line-input col-md-20">
                                        <label>所属栏目</label>
                                        <div class="input-group">
                                            <input type="text" name="column" id="column"
                                                   value="$!{data.column}"
                                                   class="form-control" style="display: none">
                                            <input type="text" id="columnName"
                                                   name="columnName" value="$!{columnName}"
                                                   class="form-control" disabled>
                                            <span class="input-group-btn">
                                            <button type="button" id="columnSelect"
                                                    class="btn btn-info btn-flat">选择</button>
                                         </span>
                                        </div>

                                    </div>-->
                                    <div class="row">
                                        <div class="form-group form-md-line-input col-md-12">
                                            <label>描述</label>
                                            <textarea class="form-control" rows="3" name="description"
                                                      id="description" maxlength="255" placeholder="填写描述"
                                                      value="$!{data.description}"></textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <input type="text" style="display: none" name="_csrf" value="${_csrf.token}"/>
                            <input  type="text" style="display: none" name="_csrf_header" value="${_csrf.headerName}"/>

                            <div class="box-footer">
                                #if($shiro.hasPermission("qy:wxQrcode:edit"))
                                <input class="btn btn-primary" id="save" value="保存" type="submit">
                                #end
                                <a href="#springUrl('/a/wxQrcode/list')" class="btn btn-default">取消</a>
                            </div>
                        </form>
                        <!-- /.box-body -->
                    </div><!-- /.box -->


                </div><!-- /.col -->
            </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->


    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->

<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- Select2 -->
<script src="plugins/select2/select2.full.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<!-- ztree -->
<script src="plugins/ztree/js/jquery.ztree.all.min.js"
        type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
<script src="plugins/security/sha256.js" type="text/javascript"></script>
<script src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<script src="js/jquery.form.min.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/lang/zh-cn/zh-cn.js"></script>
<script src="common/js/cfapp.js"></script>
<script src="common/component/uePicPicker.js"></script>
<script src="js/jquery.serializejson.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<script>

    $().ready(function () {
        Cfapp.init();
        recdTypeAdd.init();
    });
    //选择栏目



    var recdTypeAdd = function () {
        var initForm = function () {
            var initFormCtrl = function () {
                bindEvent();
            };
            var bindEvent = function () {

                var typeSelect = $('#typeselect').select2({
                    placeholder: '选择分类'
                });

                var typeValue = $('#type').val();
                if (typeValue && typeValue != '') {
                    typeSelect.val(typeValue).trigger("change");
                } else {
                    typeSelect.val('0').trigger("change");
                    $('#type').val('0');
                }

                var qrcodeUri = $('#qrcodeUri').val();
                if (qrcodeUri && qrcodeUri != '') {
                    $('#qrcordDisplay').attr('src', 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='+qrcodeUri);
                }

                $("#typeselect").on("select2:select",function(e){
                    //选中值
                    var typeVal = typeSelect.val();
                    $('#type').val(typeVal);
                });


                $("#myForm").validate({
                    rules: {
                        qty: {
                            required: true,
                            digits: true,
                            min:1
                        }
                    },
                    messages: {
                        qty: {
                            required: "数量必须填写",
                            digits: "请输入数字",
                            min: "输入的数字需要大于0"
                        }
                    },
                    submitHandler: function (form) {

                        $("#save").attr("disabled", true);
                        var formdata = $("#myForm").serializeJSON();
                        var warningMsg = Cfapp.warning({
                            content: '正在生成中，请稍后!',  //
                            title: "提示"
                        });
                        $.ajax(
                            {
                                type: "POST",
                                dataType: "json",
                                url: "#springUrl('/a/wxQrcode/pformData')",
                                data:formdata,
                                success:function (returnobj) {
                            warningMsg.destory();
                            $("#save").attr("disabled", false);
                            if (returnobj.errorNo == 2) {  //保存成功
                                Cfapp.confirm({
                                    message: "添加成功",
                                    btnoktext: "继续添加",
                                    btncanceltext: "关闭",
                                    success: function () {
                                        location.href = "#springUrl('/a/wxQrcode/form')";
                                    },
                                    cancel: function () {
                                        location.href = "#springUrl('/a/wxQrcode/list')";
                                    }
                                });
                            } else if (returnobj.errorNo == 0) {  //修改成功
                                Cfapp.alert({
                                    message: "更新成功",
                                    btntext: "确定",
                                    success: function () {
                                        location.href = "#springUrl('/a/wxQrcode/list')";
                                    }
                                });
                            } else {
                                Cfapp.alert({
                                    message: "创建失败",
                                    btntext: "确定",
                                    success: function () {
                                        location.href = "#springUrl('/a/wxQrcode/list')";
                                    }
                                });
                            }
                        } });
                    }
                })
            }
            initFormCtrl();
        }
        return {

            //main function to initiate the module
            init: function () {
                initForm();
            }

        };
    }();
</script>
</body>
<!-- END BODY -->
</html>