1. <legend id='MHk7R'><style id='MHk7R'><dir id='MHk7R'><q id='MHk7R'></q></dir></style></legend>

    <tfoot id='MHk7R'></tfoot>
      <bdo id='MHk7R'></bdo><ul id='MHk7R'></ul>
  2. <i id='MHk7R'><tr id='MHk7R'><dt id='MHk7R'><q id='MHk7R'><span id='MHk7R'><b id='MHk7R'><form id='MHk7R'><ins id='MHk7R'></ins><ul id='MHk7R'></ul><sub id='MHk7R'></sub></form><legend id='MHk7R'></legend><bdo id='MHk7R'><pre id='MHk7R'><center id='MHk7R'></center></pre></bdo></b><th id='MHk7R'></th></span></q></dt></tr></i><div id='MHk7R'><tfoot id='MHk7R'></tfoot><dl id='MHk7R'><fieldset id='MHk7R'></fieldset></dl></div>

    <small id='MHk7R'></small><noframes id='MHk7R'>

      layer.open获取数据以及回显实例代码

      时间:2023-11-08

      <tfoot id='RVktl'></tfoot>

    1. <legend id='RVktl'><style id='RVktl'><dir id='RVktl'><q id='RVktl'></q></dir></style></legend>
      1. <i id='RVktl'><tr id='RVktl'><dt id='RVktl'><q id='RVktl'><span id='RVktl'><b id='RVktl'><form id='RVktl'><ins id='RVktl'></ins><ul id='RVktl'></ul><sub id='RVktl'></sub></form><legend id='RVktl'></legend><bdo id='RVktl'><pre id='RVktl'><center id='RVktl'></center></pre></bdo></b><th id='RVktl'></th></span></q></dt></tr></i><div id='RVktl'><tfoot id='RVktl'></tfoot><dl id='RVktl'><fieldset id='RVktl'></fieldset></dl></div>
          <tbody id='RVktl'></tbody>
      2. <small id='RVktl'></small><noframes id='RVktl'>

                <bdo id='RVktl'></bdo><ul id='RVktl'></ul>
                list页面配置
                // 行事件绑定
                 table.on('tool(test)', function (obj) {
                            var data = obj.data;
                            if (obj.event === "edit") {
                                //eg2
                                layer.open({
                                    title: '修改分类'
                                    , type: 2
                                    , btn: ['提交']
                                    , content: 'edit.html'
                                    , area: ['720px', '680px']
                                    , shadeClose: false
                                    , move: false
                                    , scrollbar: false
                                    , success: function (layero, index) {
                                        // 数据回显
                                        var body = layer.getChildFrame('body', index);
                                        body.find('input[name="title"]').val(data.title);
                                        body.find('input[name="sort"]').val(data.sort);
                                        body.find('input[name="imgUrl"]').val(data.imgUrl);
                                        body.find('textarea[name="remark"]').val(data.remark);
                                        body.find('select[name="stated"]').val(data.stated);
                                        body.find('select[name="pageCode"]').val(data.pageCode);
                                        body.find('input[name="outUrl"]').val(data.outUrl);
                                        body.find('img[id="demo1"]').attr("src",imgUrl+data.imgUrl);
                                    }
                                    , yes: function (index, layero) {
                                        // 点击确定后获取弹窗数据
                                        var body = layer.getChildFrame('body', index);
                                        let title = body.find('input[name="title"]')[0].value;
                                        let sort = body.find('input[name="sort"]')[0].value;
                                        let imgUrl = body.find('input[name="imgUrl"]')[0].value;
                                        let remark = body.find('textarea[name="remark"]')[0].value;
                                        let stated = body.find('select[name="stated"]')[0].value;
                                        let pageCode = body.find('select[name="pageCode"]')[0].value;
                                        let outUrl = body.find('input[name="outUrl"]')[0].value;
                                        if (title.length < 1) {
                                            layer.msg("请输入轮播图名称");
                                            return false;
                                        }
                                        if (imgUrl.length < 8) {
                                            layer.msg("请上传图片");
                                            return false;
                                        }
                                        if (imgUrl.length < 8) {
                                            layer.msg("请上传图片");
                                            return false;
                                        }
                                        $.ajax({
                                            url: url + "/sys/b/update"
                                            , type: "post"
                                            , data: {
                                                token: localStorage.getItem("token"),
                                                id: data.id,
                                                title: title,
                                                sort: sort,
                                                imgUrl: imgUrl,
                                                stated: stated,
                                                pageCode: pageCode,
                                                outUrl: outUrl,
                                                remark: remark
                                            },
                                            success: function (res) {
                                                layer.msg(res.message, {time: 1500}, function () {
                                                    if (res.code == "200") {
                                                        layer.closeAll();
                                                        window.location.reload();
                                                    } else if (res.code == "201") {
                                                        window.location = "../login.html";
                                                    }
                                                })
                                            }
                                        })
                                    },
                                    cancel: function () {
                                        //右上角关闭回调
                                        layer.msg("已取消",{time:1500},function () {
                                            layer.closeAll();
                                        });
                                    }
                                });
                            } else if (obj.event === "del") {
                                layer.confirm("确定删除么?", {
                                    btn: ["确定", "取消"]
                                }, function () {
                                    $.ajax({
                                        url:url+"/sys/b/del",
                                        type:"post",
                                        data:{
                                            token:localStorage.getItem("token"),
                                            id:data.id
                                        },
                                        success:function (res) {
                                            layer.msg(res.message, {time: 1500}, function () {
                                                if (res.code == "200") {
                                                    layer.closeAll();
                                                    window.location.reload();
                                                } else if (res.code == "201") {
                                                    window.location = "../login.html";
                                                }
                                            })
                                        }
                                    })
                                })
                            }
                        })
                弹框数据
                <form class="layui-form" >
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题</label>
                        <div class="layui-input-inline">
                            <input type="text" name="title" value="" placeholder="标题" maxlength="10"
                                   autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-inline">
                            <input type="number" name="sort" value="0" placeholder="排序" maxlength="10"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">位置</label>
                        <div class="layui-input-inline">
                            <select name="pageCode" lay-filter="page_code" id="page_code">
                                <option value="HOME_PAGE">首页</option>
                            </select>
                        </div>
                        <label class="layui-form-label">展示/隐藏</label>
                        <div class="layui-input-inline">
                            <select name="stated" lay-filter="stated" id="stated">
                                <option value="1">展示</option>
                                <option value="0">隐藏</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">链接</label>
                        <div class="layui-input-inline">
                            <input type="text" name="outUrl" value="" placeholder="请输入链接" maxlength="10"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">图</label>
                        <div class="layui-input-inline">
                            <div class="layui-upload">
                                <button type="button" class="layui-btn" id="test1">上传图片</button>
                                <div class="layui-upload-list">
                                    <img class="layui-upload-img" id="demo1" style="width: 200px;height: 175px;margin-top: 8px">
                                    <input type="hidden" name="imgUrl" id="imgUrl">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-inline">
                            <textarea placeholder="请输入内容最多150个字符" maxlength="150" style="width: 350px;height: 180px;resize: none" name="remark" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </form>
                <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
                <script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
                <script src="../../js/jquery/dist/jquery.js" charset="utf-8"></script>
                <script src="../../js/common.js" charset="utf-8"></script>
                <!-- 注意:如果你直接复制所有代码到本地,上述 JS 路径需要改成你本地的 -->
                <script>
                    // 加载需要的组件如:上传、日期等
                    //常规使用 - 普通图片上传
                    layui.use(['upload','form'], function () {
                        var upload = layui.upload;
                        var form = layui.form;
                        form.render();
                        upload.render({
                            elem: '#test1'
                            , size: 1024 * 1204
                            , exts: 'png|jpg|jpeg' //只允许上传压缩文件
                            , url: url + '/upload?token=' + localStorage.getItem("token") //改成您自己的上传接口
                            , before: function (obj) {
                                //预读本地文件示例,不支持ie8
                                obj.preview(function (index, file, result) {
                                    $('#demo1').attr('src', result); //图片链接(base64)
                                });
                                layer.msg('上传中', {icon: 16, time: 0});
                            }
                            , done: function (res) {
                                layer.msg(res.message, {time: 1500}, function () {
                                    $("#imgUrl").val(res.data);
                                })
                            }
                        });
                    });
                 
                </script>
                如果需要对编辑器进行数据回显:一定要在build之前进行赋值
                 var detailHtml = localStorage.getItem("detailHtml");
                  $("#detail_area").val(detailHtml);
                  let index= layedit.build('detail_area', {});
                 
                上一篇:layui获取select选中的值 下一篇:没有了

                相关文章

                最新文章

                • <bdo id='2L4YE'></bdo><ul id='2L4YE'></ul>

                  <legend id='2L4YE'><style id='2L4YE'><dir id='2L4YE'><q id='2L4YE'></q></dir></style></legend>

                    <tfoot id='2L4YE'></tfoot>
                    <i id='2L4YE'><tr id='2L4YE'><dt id='2L4YE'><q id='2L4YE'><span id='2L4YE'><b id='2L4YE'><form id='2L4YE'><ins id='2L4YE'></ins><ul id='2L4YE'></ul><sub id='2L4YE'></sub></form><legend id='2L4YE'></legend><bdo id='2L4YE'><pre id='2L4YE'><center id='2L4YE'></center></pre></bdo></b><th id='2L4YE'></th></span></q></dt></tr></i><div id='2L4YE'><tfoot id='2L4YE'></tfoot><dl id='2L4YE'><fieldset id='2L4YE'></fieldset></dl></div>

                    <small id='2L4YE'></small><noframes id='2L4YE'>