123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>layui</title>
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
- <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all"/>
- <link rel="stylesheet" href="__CSS__/admin.css" media="all">
- <style type="text/css">
- /* tooltip */
- #tooltip {
- position: absolute;
- border: 1px solid #ccc;
- background: #333;
- padding: 2px;
- display: none;
- color: #fff;
- }
- </style>
- </head>
- <body style="padding:10px;">
- <div class="tplay-body-div">
- {include file="user/tab"}
- <form class="layui-form serch" action="{:url('index')}" method="post">
- <div class="layui-form-item" style="float: left;">
- <div class="layui-input-inline" style="width: 90px;">
- <input type="text" name="id" lay-verify="title" autocomplete="off" placeholder="消息ID"
- class="layui-input layui-btn-sm">
- </div>
- <div class="layui-input-inline" style="width: 90px;">
- <input type="text" name="from_user_id" lay-verify="title" autocomplete="off" placeholder="发送人ID"
- class="layui-input layui-btn-sm">
- </div>
- <div class="layui-input-inline" style="width: 90px;">
- <input type="text" name="to_user_id" lay-verify="title" autocomplete="off" placeholder="接收人ID"
- class="layui-input layui-btn-sm">
- </div>
- <div class="layui-input-inline">
- <input type="text" name="keywords" lay-verify="title" autocomplete="off" placeholder="查找内容"
- class="layui-input layui-btn-sm">
- </div>
- <div class="layui-input-inline">
- <input type="text" name="ip" lay-verify="title" autocomplete="off" placeholder="IP"
- class="layui-input layui-btn-sm">
- </div>
- <div class="layui-input-inline">
- <input type="text" class="layui-input" id="time_range" placeholder="时间" autocomplete="off"
- name="create_time">
- </div>
- <div class="layui-input-inline" style="width: 90px;">
- <select name="is_look" lay-search="">
- <option value="">阅读状态</option>
- <option value="0">未读</option>
- <option value="1">已读</option>
- </select>
- </div>
- <div class="layui-input-inline" style="width: 90px;">
- <select name="status" lay-search="">
- <option value="">审核</option>
- <option value="0">待审核</option>
- <option value="1">已审核</option>
- <option value="-1">已拒绝</option>
- </select>
- </div>
- <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
- </div>
- </form>
- <script type="text/html" id="toolbarDemo">
- <div class="layui-btn-container">
- <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deletes">批量删除</button>
- <button class="layui-btn layui-btn-sm" lay-event="sysmessage">回复消息</button>
- <button class="layui-btn layui-btn-sm" lay-event="sendmessage">发送公告</button>
- </div>
- </script>
- <script type="text/html" id="barDemo">
- <div class="layui-btn-group">
- <button class="layui-btn layui-btn-xs a_menu" lay-event="edit"><i class="layui-icon"
- style="margin-right: 0;"></i></button>
- <button class="layui-btn layui-btn-xs delete" lay-event="del"><i class="layui-icon"
- style="margin-right: 0;"></i></button>
- </div>
- </script>
- <table class="layui-table" id="table" lay-filter="table"></table>
- {include file="public/foot"}
- <script type="text/javascript">
- layui.use(['table', 'layer', 'form'], function () {
- var table = layui.table,
- form = layui.form,
- layer = layui.layer;
- //第一个实例
- table.render({
- id: 'table'
- , elem: '#table'
- , size: 'sm' //小尺寸的表格
- , toolbar: '#toolbarDemo'
- // , defaultToolbar: []
- , limit: 15
- , limits: [15, 20, 30, 40, 50, 100]
- , url: "{:url('index')}" //数据接口
- , page: true //开启分页
- , cols: [[ //表头
- {type: 'checkbox'},
- {field: 'id', title: 'ID', width: 60},
- {field: 'from_user', title: '消息发送人', width: 160},
- {field: 'message', title: '内容', minWidth:200},
- {field: 'to_user', title: '消息接收人', width: 160},
- {field: 'to_msg_id', title: '回复消息ID', width: 160},
- {field: 'create_time', title: '时间', width: 160},
- {
- field: 'is_look', title: '阅读状态', align: 'center', width: 80, templet: function (row) {
- return '<a href="javascript:;" style="font-size:18px;" class="is_look" data-id="' + row.id + '" data-val="' + row.is_look + '">' + (row.is_look == 1 ? '<i class="fa fa-toggle-on"></i>' : '<i class="fa fa-toggle-off"></i>') + '</a>';
- }
- },
- {
- field: 'status', title: '审核', width: 80, fixed: 'right', templet: function (row) {
- if (row.status == 1) {
- return '<span class="layui-badge status" style="background-color: #8FCDA0" data-id="'+row.id+'">'+row.status_text+'</span>';
- } else if (row.status == -1) {
- return '<span class="layui-badge status" data-id="'+row.id+'">'+row.status_text+'</span>';
- } else {
- return '<span class="layui-badge layui-bg-gray status" data-id="'+row.id+'">'+row.status_text+'</span>';
- }
- }
- },
- {field: 'ip', title: 'IP', width: 100},
- // {field: 'action', title: '操作', align: 'center', toolbar: '#barDemo', fixed: 'right',width:100}
- ]],
- done: function () {
- switchLook();
- switchStatus(table);
- }
- });
- form.on('submit(serch)', function (data) {
- table.reload('table', {
- where: data.field
- , page: {
- curr: 1 //重新从第 1 页开始
- }
- });
- return false;
- });
- //编辑
- table.on('tool(table)', function (obj) {
- if (obj.event == 'edit') {
- location.href = "{:url('publish')}?id=" + obj.data.id;
- }
- else if (obj.event == 'del') {
- layer.confirm('确定要删除?', function (index) {
- $.ajax({
- url: "{:url('delete')}",
- dataType: 'json',
- data: {id: obj.data.id},
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- table.reload('table');
- }
- }
- })
- })
- }
- //
- });
- //监听事件
- table.on('toolbar(table)', function (obj) {
- if (obj.event == 'deletes') {
- var checkStatus = table.checkStatus(obj.config.id);//获取选中的数据
- var data = checkStatus.data;
- if (data.length > 0) {
- var ids = [];//数组
- data.forEach(function (item, key) {
- ids[key] = item.id;
- })
- layer.confirm('是否删除?', function (index, layero) {
- $.ajax({
- url: "{:url('deletes')}",
- dataType: 'json',
- data: {"ids": ids},
- type: 'post',
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- table.reload('table');
- }
- }
- })
- layer.close(index)
- });
- } else {
- layer.msg('请先勾选,需要操作的记录');
- }
- }
- else if (obj.event == 'sysmessage') {
- var checkStatus = table.checkStatus(obj.config.id);//获取选中的数据
- var data = checkStatus.data;
- if (data.length > 0) {
- var ids = [];//数组
- data.forEach(function (item, key) {
- ids[key] = item.id;
- })
- layer.prompt({
- formType: 2,
- anim: 1,
- title: '请输入内容',
- skin: 'demo-class',
- area: ['280px', '150px'],
- id: 'remember',//设定一个id,防止重复弹出
- moveType: 1, //拖拽模式,0或者1
- }, function (value, index, elem) {
- layer.confirm('确认发送?', function (index2, layero) {
- $.ajax({
- url: "{:url('sysmessage')}",
- dataType: 'json',
- data: {"ids": ids, message: value},
- type: 'post',
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- table.reload('table');
- }
- }
- });
- layer.close(index2);
- layer.close(index);
- });
- })
- } else {
- layer.msg('请先勾选,需要回复的消息');
- }
- }
- else if(obj.event == 'sendmessage'){
- window.parent.document.getElementById('tag').click();
- }
- });
- });
- </script>
- <script>
- function switchLook() {
- $('.is_look').click(function () {
- var val = $(this).attr('data-val');
- var id = $(this).attr('data-id');
- var i = $(this).find('i');
- var the = $(this);
- if (val == 1) {
- var status = 0;
- } else {
- var status = 1;
- }
- $.ajax({
- type: "post",
- url: "{:url('look')}",
- dataType: 'json',
- data: {id: id, status: status},
- success: function (res) {
- if (res.code == 1) {
- tostatus();
- } else {
- layer.msg(res.msg);
- }
- }
- })
- function tostatus() {
- if (val == 1) {
- i.attr("class", "fa fa-toggle-off");
- the.attr('data-val', 0);
- } else {
- i.attr("class", "fa fa-toggle-on");
- the.attr('data-val', 1);
- }
- }
- })
- }
- function switchStatus(table) {
- $('.status').click(function () {
- var id = $(this).attr('data-id');
- layer.msg('审核', {
- time: 20000,
- btn: ['通过', '拒绝','待审', '再想想'],
- yes: function (index, layero) {
- $.ajax({
- url: "{:url('admin/tomessages/status')}",
- type: 'post',
- dataType: 'json', data: {id: id, status: '1'},
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- table.reload('table');
- }
- }
- })
- },
- btn2: function (index, layero) {
- $.ajax({
- url: "{:url('admin/tomessages/status')}",
- type: 'post',
- dataType: 'json', data: {id: id, status: '-1'},
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- table.reload('table');
- }
- }
- })
- }
- ,btn3: function(index, layero){
- $.ajax({
- url: "{:url('admin/tomessages/status')}",
- type: 'post',
- dataType: 'json', data: {id: id, status: '0'},
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- table.reload('table');
- }
- }
- })
- },
- })
- })
- }
- </script>
- </div>
- </body>
- </html>
|