<!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">
    <link rel="stylesheet" href="common/css/uePicPicker.css">
    <style>
        .previewImg {
            max-width: 100%;
            max-height: 100%;
            border: 0px;
            display: none;
            z-index: 999;
        }
    </style>
    <!-- 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">
    <!--fileinput css-->
    <link rel="stylesheet" href="plugins/bootstrap-fileinput/bootstrap-fileinput.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 id="hiddenDiv" style="display:none">$!{data.content_exhibi}</div>
    <div id="hiddenDivEn" style="display:none">$!{data.content_exhibi_en}</div>
    <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"/>
                            <div class="box-body">

                                <div class="form-group form-md-line-input col-md-12">
                                    <label>展会标题(CN)</label>
                                    <input type="text"
                                           class="form-control htmlescape required " name="exhibi_title"
                                           id="exhibi_title"
                                           maxlength="100" placeholder="展会标题(CN)"
                                           value="$!{data.exhibi_title}"

                                    >

                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>展会标题(EN)</label>
                                    <input type="text"
                                           class="form-control col-md-12" name="exhibi_title_en"
                                           id="exhibi_title_en"
                                           maxlength="200" placeholder="展会标题(EN)"
                                           value="$!{data.exhibi_title_en}"
                                           required="required"
                                    >
                                </div>



                                <div class="form-group form-md-line-input col-md-12">
                                    <label>展位号(Exhibi_number)</label>
                                    <input type="text"
                                           class="form-control htmlescape required " name="exhibi_number"
                                           id="exhibi_number"
                                           maxlength="50" placeholder="展位号"
                                           value="$!{data.exhibi_number}"

                                    >

                                </div>

                                <div class="form-group form-md-line-input col-md-12">
                                    <label>展会类型(Exhibi_type)</label>
                                    <select class="form-control" name = "exhibi_type" value="exhibi_type">
                                        #if($data.exhibi_type==0)
                                        <option selected value="0">汽车(Car)</option>
                                        <option value="1">工业(Industry)</option>
                                        #else
                                        <option value="0">汽车(Car)</option>
                                        <option selected value="1">工业(Industry)</option>
                                        #end
                                    </select>
                                </div>

                                <div class="form-group form-md-line-input col-md-12">
                                    <label>是否发布(Is_Release)</label>
                                    <select class="form-control" name = "releas" value="releas">
                                        #if($data.releas==0)
                                        <option selected value="0">发布(Is_Release)</option>
                                        <option value="1">未发布(No_Release)</option>
                                        #else
                                        <option value="0">发布(Is_Release)</option>
                                        <option selected value="1">未发布(No_Release)</option>
                                        #end
                                    </select>
                                </div>

                                <div class="form-group form-md-line-input col-md-12">
                                    <label>展会内容(CN)</label>
                                    <script id="ueditor" style="" type="text/plain"></script>
                                </div>
                                <div class="form-group form-md-line-input col-md-12 ">
                                    <label>展会内容(EN)</label>
                                    <script id="ueditor1" style="" type="text/plain"></script>
                                </div>



                                <!--展会图片-->
                                <div class="form-group form-md-line-input col-md-12" id="imageurl">


                                </div>
                                <!--展会推送封面图-->
                                <div class="form-group form-md-line-input col-md-12" id="imageur2">


                                </div>
                                <div class="form-group form-md-line-input col-md-12">
                                    <label>展会描述(CN)</label>
                                    <textarea type="text"
                                           class="form-control htmlescape" name="exhibi_describe"
                                           id="exhibi_describe"
                                            placeholder="展会描述(CN)"
                                    >$!{data.exhibi_describe}</textarea>

                                </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="form-group form-md-line-input col-md-12">
                                    <label>展会描述(EN)</label>
                                    <textarea type="text"
                                           class="form-control" name="exhibi_describe_en"
                                           id="exhibi_describe_en"
                                           placeholder="展会描述(EN)"
                                    >$!{data.exhibi_describe_en}</textarea>

                                </div>

                                <div class="form-group form-md-line-input col-md-12">
                                    <label>是否显示展品信息(Is_Show_Exhibits)</label>
                                    <select class="form-control" name = "show_exhibits" value="show_exhibits">
                                        #if($data.show_exhibits == 0)
                                        <option selected value="0">是</option>
                                        <option value="1">否</option>
                                        #else
                                        <option  value="0">是</option>
                                        <option value="1" selected>否</option>
                                        #end
                                    </select>
                                </div>

                                <div class="form-group form-md-line-input col-md-12">
                                    <label>是否显示相关问询(Is_Show_inquiries)</label>
                                    <select class="form-control" name = "show_inquiries" value="show_inquiries">
                                        #if($data.show_inquiries == 0)
                                        <option selected value="0">是</option>
                                        <option value="1">否</option>
                                        #else
                                        <option  value="0">是</option>
                                        <option selected value="1">否</option>
                                        #end
                                    </select>
                                </div>

                                <div class="form-group form-md-line-input col-md-12">
                                    <label>是否显示样本资料(Is_Show_sample)</label>
                                    <select class="form-control" name = "show_sample" value="show_sample">
                                        #if($data.show_sample == 0)
                                        <option selected value="0">是</option>
                                        <option value="1">否</option>
                                        #else
                                        <option  value="0">是</option>
                                        <option selected value="1">否</option>
                                        #end
                                    </select>
                                </div>

                            </div>



                            <div class="box-footer col-md-12">
                                #if($shiro.hasPermission("qy.exhibi.edit"))
                                <input class="btn btn-primary" id="save" value="保存" type="submit">
                                #end
                                <a href="#springUrl('/a/exhibi/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>
<!-- 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>
<!-- 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 type="text/javascript" charset="utf-8"
        src="plugins/ueditor-min-1.4.3/p/main.js"></script>
<script type="text/javascript" charset="utf-8"
        src="plugins/ueditor-min-1.4.3/q/main.js"></script>
<script src="common/js/cfapp.js"></script>
<script src="plugins/Sortable/Sortable.min.js"></script>
<script src="common/component/uePicPicker.js"></script>
<script src="common/component/ueSPicPicker.js"></script>
<script src="js/jquery.serializejson.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<script>
    var ue = null;
    var uen = null;
    var coverPP = null;
    var coverPP2 = null;
    var initPicsSel = function () {

        var smallimg = "$!{data.exhibi_picture}";
        coverPP = new uePicPicker({
            tarId: 'imageurl', //根据tarId 找到图片放入位置
            title: '展会图片',
            sizeDes: '544*350',
            max: 1,   //最多可选几个
            datas: smallimg=='' ? null : smallimg.split(","),//如果有多个图片路径就用逗号分割
            success: null  //回调函数
        });

        var smallimg1 = "$!{data.exhibi_cover}";
        coverPP2 = new uePicPicker({
            tarId: 'imageur2', //根据tarId 找到图片放入位置
            title: '推送图片',
            sizeDes: '360*200',
            max: 1,   //最多可选几个
            datas: smallimg1=='' ? null : smallimg1.split(","),//如果有多个图片路径就用逗号分割
            success: null  //回调函数
        });
        coverPP.init();
        coverPP2.init();
    };


    $().ready(function () {


        ue = UE.getEditor('ueditor', {
            toolbars: [[
                'insertimage',
                'insertvideo',
                'redo', //重做
                'bold', //加粗
                'indent', //首行缩进
                'italic', //斜体
                'underline', //下划线
                'strikethrough', //删除线
                'subscript', //下标
                'fontborder', //字符边框
                'superscript', //上标
                'formatmatch', //格式刷
                'source', //源代码
                'blockquote', //引用
                'pasteplain', //纯文本粘贴模式
                'selectall', //全选
                'print', //打印
                'preview', //预览
                'horizontal', //分隔线
                'removeformat', //清除格式
                'time', //时间
                'date', //日期
                'unlink', //取消链接
                'insertrow', //前插入行
                'insertcol', //前插入列
                'mergeright', //右合并单元格
                'mergedown', //下合并单元格
                'deleterow', //删除行
                'deletecol', //删除列
                'splittorows', //拆分成行
                'splittocols', //拆分成列
                'splittocells', //完全拆分单元格
                'deletecaption', //删除表格标题
                'inserttitle', //插入标题
                'mergecells', //合并多个单元格
                'deletetable', //删除表格
                'cleardoc', //清空文档
                'insertparagraphbeforetable', //"表格前插入行"
                'insertcode', //代码语言
                'fontfamily', //字体
                'fontsize', //字号
                'paragraph', //段落格式
                'edittable', //表格属性
                'edittd', //单元格属性
                'link', //超链接
                'emotion', //表情
                'spechars', //特殊字符
                'insertvideo', //视频
                'help', //帮助
                'justifyleft', //居左对齐
                'justifyright', //居右对齐
                'justifycenter', //居中对齐
                'justifyjustify', //两端对齐
                'forecolor', //字体颜色
                'backcolor', //背景色
                'insertorderedlist', //有序列表
                'insertunorderedlist', //无序列表
                'fullscreen', //全屏
                'directionalityltr', //从左向右输入
                'directionalityrtl', //从右向左输入
                'rowspacingtop', //段前距
                'rowspacingbottom', //段后距
                'pagebreak', //分页
                'insertframe', //插入Iframe
                'imagenone', //默认
                'imageleft', //左浮动
                'imageright', //右浮动
                'attachment', //附件
                'imagecenter', //居中
                'wordimage', //图片转存
                'lineheight', //行间距
                'edittip ', //编辑提示
                'customstyle', //自定义标题
                'autotypeset', //自动排版
                'touppercase', //字母大写
                'tolowercase', //字母小写
                'template', //模板
                'inserttable', //插入表格
                'drafts', // 从草稿箱加载
                'charts', // 图表
            ]]
        });
        //中文编辑表
        ue.addListener("ready", function () {
           var hiddenHtml = $("#hiddenDiv").html();
            ue.setContent(hiddenHtml);
        });



        uen = UE.getEditor('ueditor1', {
            toolbars: [[
                'insertimage',
                'insertvideo',
                'redo', //重做
                'bold', //加粗
                'indent', //首行缩进
                'italic', //斜体
                'underline', //下划线
                'strikethrough', //删除线
                'subscript', //下标
                'fontborder', //字符边框
                'superscript', //上标
                'formatmatch', //格式刷
                'source', //源代码
                'blockquote', //引用
                'pasteplain', //纯文本粘贴模式
                'selectall', //全选
                'print', //打印
                'preview', //预览
                'horizontal', //分隔线
                'removeformat', //清除格式
                'time', //时间
                'date', //日期
                'unlink', //取消链接
                'insertrow', //前插入行
                'insertcol', //前插入列
                'mergeright', //右合并单元格
                'mergedown', //下合并单元格
                'deleterow', //删除行
                'deletecol', //删除列
                'splittorows', //拆分成行
                'splittocols', //拆分成列
                'splittocells', //完全拆分单元格
                'deletecaption', //删除表格标题
                'inserttitle', //插入标题
                'mergecells', //合并多个单元格
                'deletetable', //删除表格
                'cleardoc', //清空文档
                'insertparagraphbeforetable', //"表格前插入行"
                'insertcode', //代码语言
                'fontfamily', //字体
                'fontsize', //字号
                'paragraph', //段落格式
                'edittable', //表格属性
                'edittd', //单元格属性
                'link', //超链接
                'emotion', //表情
                'spechars', //特殊字符
                'insertvideo', //视频

                'justifyleft', //居左对齐
                'justifyright', //居右对齐
                'justifycenter', //居中对齐
                'justifyjustify', //两端对齐
                'forecolor', //字体颜色
                'backcolor', //背景色
                'insertorderedlist', //有序列表
                'insertunorderedlist', //无序列表
                'fullscreen', //全屏
                'directionalityltr', //从左向右输入
                'directionalityrtl', //从右向左输入
                'rowspacingtop', //段前距
                'rowspacingbottom', //段后距
                'pagebreak', //分页
                'insertframe', //插入Iframe
                'imagenone', //默认
                'imageleft', //左浮动
                'imageright', //右浮动
                'attachment', //附件
                'imagecenter', //居中
                'wordimage', //图片转存
                'lineheight', //行间距
                'edittip ', //编辑提示
                'customstyle', //自定义标题
                'autotypeset', //自动排版
                'touppercase', //字母大写
                'tolowercase', //字母小写

                'inserttable', //插入表格
                'drafts', // 从草稿箱加载
                'charts', // 图表
            ]]
        });
        //英文编辑表
        uen.addListener("ready", function () {
          var  hiddenHtmlen = $("#hiddenDivEn").html();
            uen.setContent(hiddenHtmlen);
        });






        Cfapp.init();
        recdTypeAdd.init();
        initPicsSel();
    });


    var recdTypeAdd = function () {
        var initForm = function () {
            var initFormCtrl = function () {
                bindEvent();
            };
            var bindEvent = function () {
                Cfapp.initFileInput({
                    uploadUrl: "#springUrl('/a/fileinput/upload')",
                    deleteUrl: "#springUrl('/a/fileinput/delete')",
                    imgs: "$!{data.exhibi_picture}",
                    ctrName: '#exhibi_pictureUpload',
                    valName: '#exhibi_picture',
                    uploadExtraData: {
                        className: 'exhibi',
                    }

                });

                $("#myForm").validate({
                    rules: {},
                    messages: {},
                    submitHandler: function (form) {
                        $("#save").attr("disabled", true);
                        var dataJson = $("#myForm").serializeJSON();
                        var picurl = coverPP.getStringValues();
                        var picurl2 = coverPP2.getStringValues();
                        dataJson.exhibi_picture = picurl.substring(0,picurl.lastIndexOf(','));
                        dataJson.exhibi_cover = picurl2.substring(0,picurl2.lastIndexOf(','));
                        dataJson.content_exhibi = ue.getContent();
                        dataJson.content_exhibi_en = uen.getContent();
                        $.post("#springUrl('/a/exhibi/formData')",dataJson, function (returnobj) {
                            $("#save").attr("disabled", false);
                            if (returnobj.errorNo == 2) {  //保存成功
                                Cfapp.confirm({
                                    message: "添加成功",
                                    btnoktext: "继续添加",
                                    btncanceltext: "关闭",
                                    success: function () {
                                        location.href = "#springUrl('/a/exhibi/form')";
                                    },
                                    cancel: function () {
                                        location.href = "#springUrl('/a/exhibi/list')";
                                    }
                                });
                            } else if (returnobj.errorNo == 0) {  //修改成功
                                Cfapp.alert({
                                    message: "更新成功",
                                    btntext: "确定",
                                    success: function () {
                                        location.href = "#springUrl('/a/exhibi/list')";
                                    }
                                });
                            }else if(returnobj.errorNo ==3){
                                Cfapp.alert({
                                    message: "同一类型下仅可发布一场展会",
                                    btntext: "确定",
                                    success: function () {

                                    }
                                });
                            } else {
                                Cfapp.alert({
                                    message: "创建失败",
                                    btntext: "确定",
                                    success: function () {
                                        return;
                                    }
                                });
                            }
                        });
                    }
                })
            }
            initFormCtrl();
        }
        return {

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

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