mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改系统通知管理,改用 layTable
This commit is contained in:
parent
e2298dc165
commit
8fd35775f1
@ -4,10 +4,11 @@ namespace app\data\controller\base;
|
||||
|
||||
use app\data\model\BaseUserMessage;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
|
||||
/**
|
||||
* 系统通知管理
|
||||
* Class Message
|
||||
* Class Notify
|
||||
* @package app\data\controller\base
|
||||
*/
|
||||
class Message extends Controller
|
||||
@ -22,10 +23,12 @@ class Message extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '系统通知管理';
|
||||
$query = BaseUserMessage::mQuery();
|
||||
$query->like('name')->equal('status')->dateBetween('create_at');
|
||||
$query->where(['deleted' => 0])->order('sort desc,id desc')->page();
|
||||
BaseUserMessage::mQuery()->layTable(function () {
|
||||
$this->title = '系统通知管理';
|
||||
}, function (QueryHelper $query) {
|
||||
$query->where(['deleted' => 0]);
|
||||
$query->like('name')->equal('status')->dateBetween('create_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,38 +1,34 @@
|
||||
{extend name="../../admin/view/main"}
|
||||
|
||||
{block name='content'}
|
||||
<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-card" data-auto="true" method="post">
|
||||
<form data-table-id="MessageTable" action="{:sysuri()}" class="layui-card layui-form" data-auto="true" method="post">
|
||||
<div class="layui-card-body">
|
||||
|
||||
<label class="layui-form-item relative block">
|
||||
<span class="color-green font-w7">通知标题</span>
|
||||
<span class="color-desc margin-left-5">Notify Title</span>
|
||||
<span class="help-label"><b>通知标题</b>Notify Title</span>
|
||||
<input class="layui-input" name="name" placeholder="请输入通知标题" required value='{$vo.name|default=""}'>
|
||||
</label>
|
||||
|
||||
<div class="layui-form-item relative block">
|
||||
<span class="color-green font-w7 label-required-prev">通知内容</span>
|
||||
<span class="color-desc margin-left-5">Notify Content</span>
|
||||
<div class="layui-form-item label-required-prev">
|
||||
<span class="help-label"><b>通知内容</b>Notify Content</span>
|
||||
<label class="relative block">
|
||||
<textarea class="layui-textarea" name="content" placeholder="请输入通知内容">{$vo.content|default=''}</textarea>
|
||||
<textarea class="layui-hide" name="content" placeholder="请输入通知内容">{$vo.content|default=''}</textarea>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
{notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}
|
||||
{notempty name='vo.code'}<input name='code' type='hidden' value='{$vo.code}'>{/notempty}
|
||||
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn" type="submit">保存数据</button>
|
||||
<button class="layui-btn layui-btn-danger" data-confirm="确定要取消编辑吗?" data-history-back type='button'>取消编辑</button>
|
||||
<button class="layui-btn layui-btn-danger" data-confirm="确定要取消编辑吗?" type='button' data-history-back>取消编辑</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>
|
||||
require(['ckeditor'], function () {
|
||||
window.createEditor('[name=content]', {height: 600});
|
||||
window.createEditor('[name=content]', {height: 530});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
@ -1,71 +1,76 @@
|
||||
{extend name="../../admin/view/main"}
|
||||
|
||||
{block name="button"}
|
||||
{extend name='../../admin/view/table'}
|
||||
|
||||
{block name='button'}
|
||||
<!--{if auth("add")}-->
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-open='{:url("add")}'>添加通知</button>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("remove")}-->
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("remove")}' data-confirm="确定要删除这些通知吗?" data-rule="id#{key}">删除通知</button>
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("remove")}' data-confirm="确定要删除这些通知吗?" data-rule="id#{id}">删除通知</button>
|
||||
<!--{/if}-->
|
||||
{/block}
|
||||
|
||||
{block name='content'}
|
||||
{block name="content"}
|
||||
<div class="think-box-shadow">
|
||||
{include file='base/message/index_search'}
|
||||
<table class="layui-table margin-top-10" lay-skin="line">
|
||||
{notempty name='list'}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='list-table-check-td think-checkbox'>
|
||||
<label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
|
||||
</th>
|
||||
<th class='list-table-sort-td'>
|
||||
<button class="layui-btn layui-btn-xs" data-reload type="button">刷 新</button>
|
||||
</th>
|
||||
<th class="text-left nowrap">通知标题</th>
|
||||
<th class="text-left nowrap">阅读次数</th>
|
||||
<th class="text-left nowrap">通知状态</th>
|
||||
<th class="text-left nowrap">创建时间</th>
|
||||
<th class="text-left nowrap"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{/notempty}
|
||||
<tbody>
|
||||
{foreach $list as $key=>$vo}
|
||||
<tr>
|
||||
<td class='list-table-check-td think-checkbox'>
|
||||
<label><input class="list-check-box" type='checkbox' value='{$vo.id}'></label>
|
||||
</td>
|
||||
<td class='list-table-sort-td'>
|
||||
<label><input class="list-sort-input" data-action-blur="{:sysuri()}" data-loading="false" data-value="id#{$vo.id};action#sort;sort#{value}" value="{$vo.sort}"></label>
|
||||
</td>
|
||||
<td class="text-left nowrap">{$vo.name|default=''}</td>
|
||||
<td class="text-left nowrap sub-strong-blue">已阅读 <b>{$vo.num_read|default=''}</b> 次</td>
|
||||
<td class="text-left nowrap">{if $vo.status eq 0}<span class="color-red">已禁用</span>{elseif $vo.status eq 1}<span class="color-green">已激活</span>{/if}</td>
|
||||
<td class="text-left nowrap">{$vo.create_at|format_datetime}</td>
|
||||
<td class='text-left nowrap'>
|
||||
|
||||
<!--{if auth("edit")}-->
|
||||
<a class="layui-btn layui-btn-sm" data-dbclick data-open="{:url('edit')}?id={$vo.id}" data-title="编辑系统通知">编 辑</a>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("state") and $vo.status eq 1}-->
|
||||
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0">禁 用</a>
|
||||
<!--{elseif auth("state") and $vo.status eq 0}-->
|
||||
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1">激 活</a>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("remove")}-->
|
||||
<a class="layui-btn layui-btn-sm layui-btn-danger" data-action="{:url('remove')}" data-confirm="确定要删除该通知吗?" data-value="id#{$vo.id}">删 除</a>
|
||||
<!--{/if}-->
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
|
||||
<table id="MessageTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name='script'}
|
||||
<script>
|
||||
$(function () {
|
||||
// 初始化表格组件
|
||||
$('#MessageTable').layTable({
|
||||
even: true, height: 'full',
|
||||
sort: {field: 'sort desc,id', type: 'desc'},
|
||||
cols: [[
|
||||
{checkbox: true, fixed: true},
|
||||
{field: 'sort', title: '排序权重', align: 'center', width: 100, sort: true, templet: '#SortInputTpl'},
|
||||
{field: 'name', title: '通知标题', align: 'left', minWidth: 140},
|
||||
{field: 'num_read', title: '阅读次数', align: 'center', minWidth: 110},
|
||||
{field: 'status', title: '通知状态', align: 'center', minWidth: 110, templet: '#StatusSwitchTpl'},
|
||||
{field: 'create_at', title: '创建时间', align: 'center', minWidth: 170, sort: true},
|
||||
{toolbar: '#toolbar', title: '操作面板', align: 'center', minWidth: 140, fixed: 'right'},
|
||||
]]
|
||||
});
|
||||
|
||||
// 数据状态切换操作
|
||||
layui.form.on('switch(StatusSwitch)', function (obj) {
|
||||
var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
|
||||
$.form.load("{:url('state')}", data, 'post', function (ret) {
|
||||
if (ret.code < 1) $.msg.error(ret.info, 3, function () {
|
||||
$('#MessageTable').trigger('reload');
|
||||
});
|
||||
return false;
|
||||
}, false);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<!-- 列表排序权重模板 -->
|
||||
<script type="text/html" id="SortInputTpl">
|
||||
<input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
|
||||
</script>
|
||||
|
||||
<!-- 数据状态切换模板 -->
|
||||
<script type="text/html" id="StatusSwitchTpl">
|
||||
<!--{if auth("state")}-->
|
||||
<input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{d.status>0?'checked':''}}>
|
||||
<!--{else}-->
|
||||
{{d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}
|
||||
<!--{/if}-->
|
||||
</script>
|
||||
|
||||
<!-- 数据操作工具条模板 -->
|
||||
<script type="text/html" id="toolbar">
|
||||
<!--{if auth('edit')}-->
|
||||
<a class="layui-btn layui-btn-primary layui-btn-sm" data-open='{:url("edit")}?id={{d.id}}'>编 辑</a>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("remove")}-->
|
||||
<a class="layui-btn layui-btn-danger layui-btn-sm" data-confirm="确定要删除问题吗?" data-action="{:url('remove')}" data-value="id#{{d.id}}">删 除</a>
|
||||
<!--{/if}-->
|
||||
</script>
|
||||
{/block}
|
@ -1,6 +1,7 @@
|
||||
<fieldset>
|
||||
<legend>条件搜索</legend>
|
||||
<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">
|
||||
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label">通知标题</label>
|
||||
<label class="layui-input-inline">
|
||||
@ -14,7 +15,7 @@
|
||||
<select class="layui-select" name="status">
|
||||
<option value=''>-- 全部 --</option>
|
||||
{foreach ['显示禁止的通知', '显示正常的通知'] as $k=>$v}
|
||||
{if $k.'' eq input('status')}
|
||||
{if isset($get.status) and $get.status eq $k.''}
|
||||
<option selected value="{$k}">{$v}</option>
|
||||
{else}
|
||||
<option value="{$k}">{$v}</option>
|
||||
|
Loading…
x
Reference in New Issue
Block a user