公告管理
Signed-off-by: kulawawa <laiyuwen@hotmail.com>
This commit is contained in:
parent
d5bff775b9
commit
7906716a29
80
application/admin/controller/BroadController.php
Normal file
80
application/admin/controller/BroadController.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 作者:修缘 联系QQ:278896498 QQ群:1054861244
|
||||
// | 声明:未经作者许可,禁止倒卖等商业运营,违者必究
|
||||
// | 另接php业务,网站制作、代理后台、gm后台、支付对接等
|
||||
// +----------------------------------------------------------------------
|
||||
// | 创建时间: 2022/1/5 22:51
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\model\Broad;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
|
||||
class BroadController extends Controller
|
||||
{
|
||||
public function index(Request $request, Broad $model)
|
||||
{
|
||||
$param = $request->param();
|
||||
$model = $model
|
||||
->field('id,context,status,starttime,endtime')
|
||||
->order('starttime');
|
||||
$data = $model->paginate($this->admin['per_page'], false, ['query' => $request->get()])->each(function ($item){
|
||||
$item['starttime'] = date("Y-m-d H:i:s",intval($item['starttime']));
|
||||
$item['endtime'] = date("Y-m-d H:i:s",intval($item['endtime']));
|
||||
return $item;
|
||||
});
|
||||
// dump($data);
|
||||
$this->assign($request->get());
|
||||
$this->assign([
|
||||
'data' => $data->toArray()['data'],
|
||||
'page' => $data->render(),
|
||||
'total' => $data->total(),
|
||||
]);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
public function add(Request $request, Broad $model)
|
||||
{
|
||||
if ($request->isPost()) {
|
||||
$param = $request->param();
|
||||
|
||||
$inset[] = [
|
||||
'context' => $param['context'],
|
||||
'status' => 1,
|
||||
'starttime' => strtotime($param['starttime']),
|
||||
'endtime' => strtotime($param['endtime']),
|
||||
];
|
||||
$result = $model->saveAll($inset);
|
||||
$result ? admin_success(lang('success'), URL_BACK) : admin_error();
|
||||
|
||||
}
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
//删除
|
||||
public function del($id, Broad $model)
|
||||
{
|
||||
if (count($model->noDeletionId) > 0) {
|
||||
if (is_array($id)) {
|
||||
if (array_intersect($model->noDeletionId, $id)) {
|
||||
return admin_error('ID为' . implode(',', $model->noDeletionId) . '的数据无法删除');
|
||||
}
|
||||
} else if (in_array($id, $model->noDeletionId)) {
|
||||
return admin_error('ID为' . $id . '的数据无法删除');
|
||||
}
|
||||
}
|
||||
|
||||
$result = $model->whereIn('id', $id)->delete();
|
||||
|
||||
return $result ? admin_success(lang('delete_success'), URL_RELOAD) : admin_error(lang('delete_error'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
92
application/admin/view/broad/add.html
Normal file
92
application/admin/view/broad/add.html
Normal file
@ -0,0 +1,92 @@
|
||||
{extend name="public/base" /}
|
||||
{block name='content'}
|
||||
{include file='public/content_header' /}
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box box-primary">
|
||||
<!-- 表单头部 -->
|
||||
<div class="box-header with-border">
|
||||
<div class="btn-group">
|
||||
<a class="btn flat btn-sm btn-default BackButton">
|
||||
<i class="fa fa-arrow-left"></i>
|
||||
返回
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<form id="dataForm" class="form-horizontal dataForm" action="" method="post"
|
||||
enctype="multipart/form-data">
|
||||
<div class="box-body">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="context" class="col-sm-2 control-label">公告内容</label>
|
||||
<div class="col-sm-10 col-md-4">
|
||||
<textarea id="context" name="context" style="width: 100%" placeholder="请输入公告内容" rows="6"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="starttime" class="col-sm-2 control-label">开始时间</label>
|
||||
<div class="col-sm-10 col-md-4">
|
||||
<input type="datetime-local" maxlength="50" id="starttime" autocomplete="off" name="starttime" class="form-control" placeholder="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="endtime" class="col-sm-2 control-label">结束时间</label>
|
||||
<div class="col-sm-10 col-md-4">
|
||||
<input type="datetime-local" maxlength="50" id="endtime" autocomplete="off" name="endtime" class="form-control" placeholder="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!--表单底部-->
|
||||
<div class="box-footer">
|
||||
{:token()}
|
||||
<div class="col-sm-2">
|
||||
</div>
|
||||
<div class="col-sm-10 col-md-4">
|
||||
{if !isset($data)}
|
||||
<div class="btn-group pull-right">
|
||||
<label class="createContinue">
|
||||
<input type="checkbox" value="1" id="_create" name="_create"
|
||||
title="继续添加数据">继续添加</label>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn flat btn-info dataFormSubmit">
|
||||
保存
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button type="reset" class="btn flat btn-default dataFormReset">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script>
|
||||
$("#dataForm").validate({
|
||||
rules: {
|
||||
|
||||
|
||||
},
|
||||
messages: {
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
{/block}
|
||||
|
87
application/admin/view/broad/index.html
Normal file
87
application/admin/view/broad/index.html
Normal file
@ -0,0 +1,87 @@
|
||||
{extend name="public/base" /}
|
||||
{block name='content'}
|
||||
{include file='public/content_header' /}
|
||||
<!--数据列表页面-->
|
||||
<section class="content">
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box">
|
||||
|
||||
<!--数据列表顶部-->
|
||||
|
||||
<div class="box-header">
|
||||
<div>
|
||||
<a title="添加" data-toggle="tooltip" class="btn btn-primary btn-sm " href="{:url('add')}">
|
||||
<i class="fa fa-plus"></i> 添加
|
||||
</a>
|
||||
<a class="btn btn-success btn-sm ReloadButton" data-toggle="tooltip" title="刷新">
|
||||
<i class="fa fa-refresh"></i> 刷新
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-body table-responsive">
|
||||
<table class="table table-hover table-bordered datatable" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>内容</th>
|
||||
<th>状态</th>
|
||||
<th>开始时间</th>
|
||||
<th>结束时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach name='data' id='item' key='data_key'}
|
||||
<tr>
|
||||
<td>{$item.id}</td>
|
||||
<td>{$item.context}</td>
|
||||
<td>{$item.status}</td>
|
||||
<td>{$item.starttime}</td>
|
||||
<td>{$item.endtime}</td>
|
||||
<td class="td-do">
|
||||
|
||||
<a class="btn btn-danger btn-xs AjaxButton" data-toggle="tooltip" title="删除"
|
||||
data-id="{$item.id}" data-confirm-title="删除确认"
|
||||
data-confirm-content='您确定要删除ID为 <span class="text-red">{$item.id}</span> 的数据吗'
|
||||
data-url="{:url('del')}">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 数据列表底部 -->
|
||||
<div class="box-footer">
|
||||
{$page|raw}
|
||||
<label class="control-label pull-right" style="margin-right: 10px; font-weight: 100;">
|
||||
<small>共{$total}条记录</small>
|
||||
<small>每页显示</small>
|
||||
|
||||
<select class="input-sm" onchange="changePerPage(this)">
|
||||
<option value="10" {if $admin.per_page==10}selected{/if}>10</option>
|
||||
<option value="20" {if $admin.per_page==20}selected{/if}>20</option>
|
||||
<option value="30" {if $admin.per_page==30}selected{/if}>30</option>
|
||||
<option value="50" {if $admin.per_page==50}selected{/if}>50</option>
|
||||
<option value="100" {if $admin.per_page==100}selected{/if}>100</option>
|
||||
</select>
|
||||
|
||||
<small>条记录</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/block}
|
||||
|
18
application/common/model/Broad.php
Normal file
18
application/common/model/Broad.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 作者:修缘 联系QQ:278896498 QQ群:1054861244
|
||||
// | 声明:未经作者许可,禁止倒卖等商业运营,违者必究
|
||||
// | 另接php业务,网站制作、代理后台、gm后台、支付对接等
|
||||
// +----------------------------------------------------------------------
|
||||
// | 创建时间: 2022/1/19 19:31
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
|
||||
class Broad extends Model
|
||||
{
|
||||
protected $table = 'qy_broad';
|
||||
protected $pk = 'id';
|
||||
}
|
@ -9,7 +9,7 @@ return [
|
||||
//基本设置:后台的基本信息设置
|
||||
'base'=>[
|
||||
//后台名称
|
||||
'name'=>'XX后台系统',
|
||||
'name'=>'游戏后台系统',
|
||||
//后台简称
|
||||
'short_name'=>'后台',
|
||||
//后台作者
|
||||
|
Loading…
x
Reference in New Issue
Block a user