layui.use(['form', 'layer', 'jquery', 'laydate'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        $ = layui.jquery,
        laydate = layui.laydate;

    //监听提交
    form.on('submit(SubmitData)', function (data) {
        //所有表单数据
        var dataArr = new Array();
        dataArr = data.field;
        var ueContent = UE.getEditor('editor').getContentTxt();
        var ueHtmlContent = UE.getEditor('editor').getContent();
        dataArr["F_Description"] = ueContent;
        dataArr["F_Content"] = ueHtmlContent;
        $.ajax({
            url: "/RepositoryCategory/SaveRepositoryCategoryContentData",
            type: "post",
            async: false,//同步请求
            contentType: "application/json",
            dataType: "text",
            cache: false,
            data: JSON.stringify(dataArr),
            // data: dataArr,
            success: function (thisResult, result) {

                if (thisResult == "True") {
                    layer.open({
                        content: '保存成功'
                         , btn: ['确定']
                         , yes: function (index, layero) {
                             layer.close(index);
                             ////刷新父窗体

                             var thisindex = parent.layer.getFrameIndex(window.name); //获取窗口索引
                             parent.layer.close(thisindex);
                         }
                            , cancel: function () {
                                var thisindex = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(thisindex);

                            }
                    });

                    return false;
                } else {
                    layui.layer.alert("保存失败!", {
                        icon: 2
                    });

                    return false;
                }

            },
            error: function (error) {
                return false;
            }
        });
        return false;
    });

})
$(function () {

    var c = UE.getEditor("editor", {
        topOffset: 0,
        autoFloatEnabled: false,
        autoHeightEnabled: false,
        autotypeset: {
            removeEmptyline: true
        },
        toolbars: [
            ['fullscreen', 'source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat', 'autotypeset', 'blockquote', 'pasteplain', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', 'rowspacingtop', 'rowspacingbottom', 'lineheight', 'indent', 'justifyleft', 'justifycenter', 'justifyright', 'fontfamily', 'fontsize', 'justifyjustify', 'touppercase', 'tolowercase', 'insertimage', 'simpleupload', 'emotion', 'insertvideo', 'map', 'date', 'time', 'spechars', 'preview', 'searchreplace'],
            ['con', 'title', 'fork', 'guide', 'division', 'other', 'mystyle']
        ],
        autoHeightEnabled: false,//是否自动长高，默认true
        allowDivTransToP: false,//禁止Div标签转换成P标签
        autoFloatEnabled: true,//是否保持toolbar的位置不动，默认true
        enableAutoSave: false,//启用自动保存
        elementPathEnabled: false,//是否启用元素路径 ，默认是true显示
        wordCount: false //是否开启字数统计
    });

    c.ready(function () {//修改器初始化完成再赋值
        var content = $("#htmlContent").val();
        c.setContent(content);


    });
});