{include file="common/header"/} <style> .upload-wrap { position: relative; display: inline-block; overflow: hidden; border: 1px solid #2d78f4; border-radius: 3px; } .upload-wrap .file-ele { position: absolute; top: 0; right: 0; opacity: 0; height: 100%; width: 100%; cursor: pointer; } .upload-wrap .file-open { width: 90px; height: 30px; line-height: 30px; text-align: center; color: #fff; background: #3385ff; } </style> <div class="LM-container"> <div class="LM-main"> <fieldset class="layui-elem-field layui-field-title"> <legend>系统消息</legend> <blockquote class="layui-elem-quote"> <div class="LM-table"> <a href="{:url('addmsg')}" class="layui-btn layui-btn-sm layui-btn-warm">添加系统消息</a> </div> </blockquote> </fieldset> <table class="layui-table" id="list" lay-filter="list"> </table> </div> </div> <script type="text/html" id="is_show"> <input type="checkbox" name="switch" value="{{d.id}}" lay-filter="is_show" lay-skin="switch" lay-text="开启|关闭" {{ d.status== 0 ? 'checked' : '' }}> </script> <script type="text/html" id="barDemo"> <input type="button" class="layui-btn layui-btn-xs" lay-event="del" value="删除"> <a href="addmsg?id={{d.id}}" class="layui-btn layui-btn-xs" >编辑</a> </script> {include file="common/footer"/} <script src="/static/plugins/jquery-3.4.1/jquery-3.4.1.min.js"></script> <script> layui.use(['form', 'table'], function () { var $ = layui.jquery, form = layui.form, table = layui.table; var tableIn = table.render({ elem: '#list', url: '{:url("sysmsg")}', method: 'post', title: '反馈意见', loading: true, toolbar: '#toolbar', //开启头部工具栏,并为其绑定左侧模板 defaultToolbar: ['filter', 'exports', 'print', "excel", { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可 title: '提示' , layEvent: 'LAYTABLE_TIPS' , icon: 'layui-icon-tips' }], cols: [[ // {checkbox: true, fixed: true}, {field: 'id', title: 'ID', width: 80, fixed: true, sort: true}, {field: 'name', title: '标题', width: 200, sort: true}, {field: 'status', title: '是否显示', width: 100, toolbar: "#is_show"}, {field: 'text', title: '说明', width: 500, sort: true}, {title: '操作', width: 150, align: "center", toolbar: "#barDemo"}, ]], limits: [10, 15, 20, 25, 50, 100], limit: 10, page: true }); table.on('tool(list)', function (obj) { var data = obj.data; let event = obj.event; switch (event) { case "del": layer.confirm('确定要删除吗', function (index) { loading = layer.load(1, {shade: [0.1, '#fff']}); $.post("{:url('del_msg')}", {id: data.id}, function (res) { layer.close(loading); layer.close(index); if (res.code == 200) { layer.msg(res.msg, {time: 1000, icon: 1}); tableIn.reload(); } else { layer.msg(res.msg, {time: 1000, icon: 2}); } }, "json") }) break; } }); // 是否显示 form.on('switch(is_show)', function (obj) { var id = this.value; var auth_open = obj.elem.checked === true ? 0 : 1; let loading = layer.load(1, {shade: [0.1, '#fff']}); $.post("{:url('update_nocice_status')}", {'id': id, 'status': auth_open}, function (res) { layer.close(loading); // layer.close(index) console.log(res) if (res.code == 200) { layer.msg(res.msg, {time: 1000, icon: 1}); // tableIn.reload(); } else { layer.msg(res.msg, {time: 1000, icon: 2}); } }, "json") }); $('#search').click(function () { var $keys = $('#name').val(); if (!$keys) { return layer.msg('请输入关键词'); } tableIn.reload({page: {page: 1}, where: {name: $keys}}); }) // setInterval(function () { // tableIn.reload(); // }, 50000) }); </script>