@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style>
    .layui-form-label {
        float: left;
        display: block;
        padding: 9px 15px;
        width: 60px;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }

    .lay-step {
        font-size: 0;
        width: 400px;
        margin: 0 auto;
        max-width: 100%;
        padding-left: 30px;
    }

    .layui-table-view {
        margin-left: 30px;
        margin-right: 10px;
    }

    .layui-input-block {
        margin-left: 90px;
        min-height: 36px;
        margin-right: 10px;
    }

    .layui-card > .layui-card-body {
        position: relative;
        padding: 10px 15px;
        line-height: 24px;
        overflow: auto;
        height: 300px;
    }
</style>
<script>
    layui.use(['jquery', 'form', 'laydate', 'optimizeSelectOption', 'common', 'step','wangEditor'], function () {
        var form = layui.form,
            $ = layui.$,
            common = layui.common,
            wangEditor = layui.wangEditor,
            step = layui.step;
        var editor = new wangEditor("#editor");
        
        editor.create();
        var keyValue = $.request("keyValue");
        //权限字段
        common.authorizeFields('stepForm');
        wcLoading.close();
        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%', //设置容器宽度
            stepWidth: '750px',
            height: '600px',
            stepItems: [{
                title: '基本信息'
            }, {
                title: '详细描述'
            }, {
                title: 'SEO选项'
            }]
        });
        form.on('submit(formStep)', function (data) {
            step.next('#stepForm');
            return false;
        });
        form.on('submit(formStep2)', function (data) {
            step.next('#stepForm');
            return false;
        });
        $('.pre').click(function () {
            step.pre('#stepForm');
        });
        $('.next').click(function () {
            step.next('#stepForm');
        });
        $(function () {
            initControl();
            if (!!keyValue) {
                common.ajax({
                    url: '/ContentManage/ArticleNews/GetFormJson',
                    dataType: 'json',
                    data: { keyValue: keyValue },
                    async: false,
                    success: function (data) {
                        common.val('stepForm', data);
                        $('#F_ImgUrlPic').attr('src', data.F_ImgUrl); //图片链接
                        editor.txt.text($("#F_Description").val());
                        common.setReadOnly('adminform');
                    }
                });
            }
            common.setReadOnly('stepForm');
            form.render();
        });
        function initControl() {
            //绑定数据源
            //类型为下拉框时
            $("#F_CategoryId").bindSelect({
                url: "/ContentManage/ArticleCategory/GetListJson",
                id: "F_Id",
                text: "F_FullName",
                search: true,
            });
        }
    });
    function previewImg(obj) {
        var img = new Image();
        img.src = obj.src;
        var height = img.height + 50; //获取图片高度
        var width = img.width; //获取图片宽度
        if (height > 500) { height = 500; };
        if (width > 500) { width = 500; };
        var imgHtml = "<img src='" + obj.src + "' style=\"height: " + (height - 43) + "px; width: " + width + "px; line-height: 25px!important;\"/>";
        //弹出层
        layer.open({
            type: 1,
            shade: 0.8,
            offset: 'auto',
            area: [width + 'px', height + 'px'],
            shadeClose: true,//点击外围关闭弹窗
            scrollbar: false,//不现实滚动条
            title: "图片预览", //不显示标题
            content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
            cancel: function () {
                //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', { time: 5000, icon: 6 });
            }
        });
    }
</script>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-carousel" id="stepForm" lay-filter="stepForm">
                <div carousel-item>
                    <div>
                        <form class="layui-form layuimini-form">
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">新闻类别</label>
                                <div class="layui-input-block">
                                    <select id="F_CategoryId" name="F_CategoryId" lay-filter="F_CategoryId" lay-search>
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">内容标题</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_Title" name="F_Title" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">URL链接</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_LinkUrl" name="F_LinkUrl" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">封面图片</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input" name="F_ImgUrl" id="F_ImgUrl" readonly="readonly">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"></label>
                                <div class="layui-input-block">
                                    <div class="layui-upload-list">
                                        <img id="F_ImgUrlPic" width="200" height="200" onclick="previewImg(this)" />
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">排序数字</label>
                                <div class="layui-input-block">
                                    <input type="number" pattern="[0-9]*" id="F_SortCode" name="F_SortCode" lay-verify="required" class="layui-input ">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">选项</label>
                                <div class="layui-input-block">
                                    <input id="F_IsTop" name="F_IsTop" type="checkbox" value="true" title="是否置顶">
                                    <input id="F_IsRed" name="F_IsRed" type="checkbox" value="true" title="是否热门">
                                    <input id="F_IsHot" name="F_IsHot" type="checkbox" value="true" title="是否推荐">
                                    <input id="F_EnabledMark" name="F_EnabledMark" type="checkbox" value="true" checked="checked" title="是否发布">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">点击次数</label>
                                <div class="layui-input-block">
                                    <input type="number" pattern="[0-9]*" id="F_Click" name="F_Click" lay-verify="required" class="layui-input" value="0">
                                </div>
                            </div>
                            <div class="form-group-bottom text-right">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="formStep">
                                        &emsp;下一步&emsp;
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div>
                        <form class="layui-form layuimini-form">
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">内容描述</label>
                                <div class="layui-input-block">
                                    <textarea  class=" layui-hide" id="F_Description" name="F_Description" type="text/plain" style="width:100%;height:400px;"></textarea>
                                    <div id="editor"></div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">摘要</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_Zhaiyao" name="F_Zhaiyao" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">来源</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_Source" name="F_Source" autocomplete="off" value="本站" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">作者</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_Author" name="F_Author" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="form-group-bottom text-right">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                    <button class="layui-btn" lay-submit lay-filter="formStep2">
                                        &emsp;下一步&emsp;
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div>
                        <form class="layui-form layuimini-form">
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">Seo标题</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_SeoTitle" name="F_SeoTitle" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">Seo关键字</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_SeoKeywords" name="F_SeoKeywords" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">Seo描述</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_SeoDescription" name="F_SeoDescription" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label">Tags标签</label>
                                <div class="layui-input-block">
                                    <input type="text" id="F_Tags" name="F_Tags" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="form-group-bottom text-right">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

