main
parent
552b498915
commit
1b33c6cfc4
@ -0,0 +1,62 @@ |
||||
<?php |
||||
|
||||
namespace app\admin\controller\content; |
||||
|
||||
use app\common\controller\Backend; |
||||
|
||||
/** |
||||
* 商城公告管理 |
||||
* |
||||
* @icon fa fa-circle-o |
||||
*/ |
||||
class Notice extends Backend |
||||
{ |
||||
|
||||
/** |
||||
* Notice模型对象 |
||||
* @var \app\admin\model\content\Notice |
||||
*/ |
||||
protected $model = null; |
||||
|
||||
public function _initialize() |
||||
{ |
||||
parent::_initialize(); |
||||
$this->model = new \app\admin\model\content\Notice; |
||||
$this->view->assign("statusList", $this->model->getStatusList()); |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 |
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 |
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 |
||||
*/ |
||||
|
||||
public function index() |
||||
{ |
||||
//设置过滤方法 |
||||
$this->request->filter(['strip_tags', 'trim']); |
||||
if ($this->request->isAjax()) { |
||||
//如果发送的来源是Selectpage,则转发到Selectpage |
||||
if ($this->request->request('keyField')) { |
||||
return $this->selectpage(); |
||||
} |
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); |
||||
$list = $this->model |
||||
// ->with('group') |
||||
->where($where) |
||||
->order($sort, $order) |
||||
->paginate($limit); |
||||
// foreach ($list as $k => $v) { |
||||
// $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname); |
||||
// $v->hidden(['password', 'salt']); |
||||
// } |
||||
$result = array("total" => $list->total(), "rows" => $list->items()); |
||||
|
||||
return json($result); |
||||
} |
||||
return $this->view->fetch(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
<?php |
||||
|
||||
return [ |
||||
'Id' => 'ID', |
||||
'Title' => '公告标题', |
||||
'Image' => '公告主图', |
||||
'Content' => '公告详情', |
||||
'Status' => '公告状态', |
||||
'Status 0' => '隐藏', |
||||
'Set status to 0'=> '设为隐藏', |
||||
'Status 1' => '正常', |
||||
'Set status to 1'=> '设为正常', |
||||
'Createtime' => '创建时间', |
||||
'Updatetime' => '更新时间' |
||||
]; |
@ -0,0 +1,15 @@ |
||||
<?php |
||||
|
||||
return [ |
||||
'Id' => 'ID', |
||||
'Title' => '公告标题', |
||||
'Image' => '公告主图', |
||||
'Content' => '公告详情', |
||||
'Status' => '公告状态', |
||||
'Status 0' => '隐藏', |
||||
'Set status to 0'=> '设为隐藏', |
||||
'Status 1' => '正常', |
||||
'Set status to 1'=> '设为正常', |
||||
'Createtime' => '创建时间', |
||||
'Updatetime' => '更新时间' |
||||
]; |
@ -0,0 +1,53 @@ |
||||
<?php |
||||
|
||||
namespace app\admin\model\content; |
||||
|
||||
use think\Model; |
||||
use think\Request; |
||||
|
||||
|
||||
class Notice extends Model |
||||
{ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名 |
||||
protected $name = 'notice'; |
||||
|
||||
// 自动写入时间戳字段 |
||||
protected $autoWriteTimestamp = 'integer'; |
||||
|
||||
// 定义时间戳字段名 |
||||
protected $createTime = 'createtime'; |
||||
protected $updateTime = 'updatetime'; |
||||
protected $deleteTime = false; |
||||
|
||||
// 追加属性 |
||||
protected $append = [ |
||||
'status_text' |
||||
]; |
||||
|
||||
|
||||
|
||||
public function getStatusList() |
||||
{ |
||||
return ['0' => __('Status 0'), '1' => __('Status 1')]; |
||||
} |
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data) |
||||
{ |
||||
$value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); |
||||
$list = $this->getStatusList(); |
||||
return isset($list[$value]) ? $list[$value] : ''; |
||||
} |
||||
|
||||
public function getImageAttr($value) { |
||||
if(!empty($value)) return Request::instance()->domain().$value; |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
namespace app\admin\validate; |
||||
|
||||
use think\Validate; |
||||
|
||||
class Notice extends Validate |
||||
{ |
||||
/** |
||||
* 验证规则 |
||||
*/ |
||||
protected $rule = [ |
||||
]; |
||||
/** |
||||
* 提示消息 |
||||
*/ |
||||
protected $message = [ |
||||
]; |
||||
/** |
||||
* 验证场景 |
||||
*/ |
||||
protected $scene = [ |
||||
'add' => [], |
||||
'edit' => [], |
||||
]; |
||||
|
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
namespace app\admin\validate\content; |
||||
|
||||
use think\Validate; |
||||
|
||||
class Notice extends Validate |
||||
{ |
||||
/** |
||||
* 验证规则 |
||||
*/ |
||||
protected $rule = [ |
||||
]; |
||||
/** |
||||
* 提示消息 |
||||
*/ |
||||
protected $message = [ |
||||
]; |
||||
/** |
||||
* 验证场景 |
||||
*/ |
||||
protected $scene = [ |
||||
'add' => [], |
||||
'edit' => [], |
||||
]; |
||||
|
||||
} |
@ -0,0 +1,47 @@ |
||||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
||||
|
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value=""> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<div class="input-group"> |
||||
<input id="c-image" data-rule="required" class="form-control" size="50" name="row[image]" type="text" value=""> |
||||
<div class="input-group-addon no-border no-padding"> |
||||
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> |
||||
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span> |
||||
</div> |
||||
<span class="msg-box n-right" for="c-image"></span> |
||||
</div> |
||||
<ul class="row list-inline faupload-preview" id="p-image"></ul> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
|
||||
<div class="radio"> |
||||
{foreach name="statusList" item="vo"} |
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label> |
||||
{/foreach} |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
<div class="form-group layer-footer"> |
||||
<label class="control-label col-xs-12 col-sm-2"></label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button> |
||||
</div> |
||||
</div> |
||||
</form> |
@ -0,0 +1,47 @@ |
||||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
||||
|
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}"> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<div class="input-group"> |
||||
<input id="c-image" data-rule="required" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}"> |
||||
<div class="input-group-addon no-border no-padding"> |
||||
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> |
||||
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span> |
||||
</div> |
||||
<span class="msg-box n-right" for="c-image"></span> |
||||
</div> |
||||
<ul class="row list-inline faupload-preview" id="p-image"></ul> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
|
||||
<div class="radio"> |
||||
{foreach name="statusList" item="vo"} |
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label> |
||||
{/foreach} |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
<div class="form-group layer-footer"> |
||||
<label class="control-label col-xs-12 col-sm-2"></label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button> |
||||
</div> |
||||
</div> |
||||
</form> |
@ -0,0 +1,46 @@ |
||||
<div class="panel panel-default panel-intro"> |
||||
|
||||
<div class="panel-heading"> |
||||
{:build_heading(null,FALSE)} |
||||
<ul class="nav nav-tabs" data-field="status"> |
||||
<li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li> |
||||
{foreach name="statusList" item="vo"} |
||||
<li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li> |
||||
{/foreach} |
||||
</ul> |
||||
</div> |
||||
|
||||
|
||||
<div class="panel-body"> |
||||
<div id="myTabContent" class="tab-content"> |
||||
<div class="tab-pane fade active in" id="one"> |
||||
<div class="widget-body no-padding"> |
||||
<div id="toolbar" class="toolbar"> |
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> |
||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('/content/notice/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> |
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('/content/notice/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> |
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('/content/notice/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> |
||||
|
||||
|
||||
<div class="dropdown btn-group {:$auth->check('/content/notice/multi')?'':'hide'}"> |
||||
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a> |
||||
<ul class="dropdown-menu text-left" role="menu"> |
||||
{foreach name="statusList" item="vo"} |
||||
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li> |
||||
{/foreach} |
||||
</ul> |
||||
</div> |
||||
|
||||
|
||||
</div> |
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" |
||||
data-operate-edit="{:$auth->check('/content/notice/edit')}" |
||||
data-operate-del="{:$auth->check('/content/notice/del')}" |
||||
width="100%"> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
</div> |
@ -0,0 +1,47 @@ |
||||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
||||
|
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value=""> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<div class="input-group"> |
||||
<input id="c-image" data-rule="required" class="form-control" size="50" name="row[image]" type="text" value=""> |
||||
<div class="input-group-addon no-border no-padding"> |
||||
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> |
||||
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span> |
||||
</div> |
||||
<span class="msg-box n-right" for="c-image"></span> |
||||
</div> |
||||
<ul class="row list-inline faupload-preview" id="p-image"></ul> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
|
||||
<div class="radio"> |
||||
{foreach name="statusList" item="vo"} |
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label> |
||||
{/foreach} |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
<div class="form-group layer-footer"> |
||||
<label class="control-label col-xs-12 col-sm-2"></label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button> |
||||
</div> |
||||
</div> |
||||
</form> |
@ -0,0 +1,47 @@ |
||||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
||||
|
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}"> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<div class="input-group"> |
||||
<input id="c-image" data-rule="required" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}"> |
||||
<div class="input-group-addon no-border no-padding"> |
||||
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> |
||||
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span> |
||||
</div> |
||||
<span class="msg-box n-right" for="c-image"></span> |
||||
</div> |
||||
<ul class="row list-inline faupload-preview" id="p-image"></ul> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
|
||||
<div class="radio"> |
||||
{foreach name="statusList" item="vo"} |
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label> |
||||
{/foreach} |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
<div class="form-group layer-footer"> |
||||
<label class="control-label col-xs-12 col-sm-2"></label> |
||||
<div class="col-xs-12 col-sm-8"> |
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button> |
||||
</div> |
||||
</div> |
||||
</form> |
@ -0,0 +1,46 @@ |
||||
<div class="panel panel-default panel-intro"> |
||||
|
||||
<div class="panel-heading"> |
||||
{:build_heading(null,FALSE)} |
||||
<ul class="nav nav-tabs" data-field="status"> |
||||
<li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li> |
||||
{foreach name="statusList" item="vo"} |
||||
<li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li> |
||||
{/foreach} |
||||
</ul> |
||||
</div> |
||||
|
||||
|
||||
<div class="panel-body"> |
||||
<div id="myTabContent" class="tab-content"> |
||||
<div class="tab-pane fade active in" id="one"> |
||||
<div class="widget-body no-padding"> |
||||
<div id="toolbar" class="toolbar"> |
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> |
||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('notice/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> |
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('notice/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> |
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('notice/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> |
||||
|
||||
|
||||
<div class="dropdown btn-group {:$auth->check('notice/multi')?'':'hide'}"> |
||||
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a> |
||||
<ul class="dropdown-menu text-left" role="menu"> |
||||
{foreach name="statusList" item="vo"} |
||||
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li> |
||||
{/foreach} |
||||
</ul> |
||||
</div> |
||||
|
||||
|
||||
</div> |
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" |
||||
data-operate-edit="{:$auth->check('notice/edit')}" |
||||
data-operate-del="{:$auth->check('notice/del')}" |
||||
width="100%"> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
</div> |
@ -0,0 +1,16 @@ |
||||
<?php |
||||
namespace app\api\controller; |
||||
|
||||
use app\common\controller\Api; |
||||
|
||||
class Notice extends Api { |
||||
protected $noNeedLogin = ['*']; |
||||
protected $noNeedRight = ['*']; |
||||
|
||||
public function list() { |
||||
$model = new \app\admin\model\content\Notice(); |
||||
$list = $model->paginate(10); |
||||
|
||||
$this->success('公告列表', $list); |
||||
} |
||||
} |
@ -0,0 +1,55 @@ |
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { |
||||
|
||||
var Controller = { |
||||
index: function () { |
||||
// 初始化表格参数配置
|
||||
Table.api.init({ |
||||
extend: { |
||||
index_url: 'content/notice/index' + location.search, |
||||
add_url: 'content/notice/add', |
||||
edit_url: 'content/notice/edit', |
||||
del_url: 'content/notice/del', |
||||
multi_url: 'content/notice/multi', |
||||
import_url: 'content/notice/import', |
||||
table: 'notice', |
||||
} |
||||
}); |
||||
|
||||
var table = $("#table"); |
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({ |
||||
url: $.fn.bootstrapTable.defaults.extend.index_url, |
||||
pk: 'id', |
||||
sortName: 'id', |
||||
columns: [ |
||||
[ |
||||
{checkbox: true}, |
||||
{field: 'id', title: __('Id')}, |
||||
{field: 'title', title: __('Title'), operate: 'LIKE'}, |
||||
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, |
||||
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status}, |
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
||||
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
||||
] |
||||
] |
||||
}); |
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table); |
||||
}, |
||||
add: function () { |
||||
Controller.api.bindevent(); |
||||
}, |
||||
edit: function () { |
||||
Controller.api.bindevent(); |
||||
}, |
||||
api: { |
||||
bindevent: function () { |
||||
Form.api.bindevent($("form[role=form]")); |
||||
} |
||||
} |
||||
}; |
||||
return Controller; |
||||
}); |
@ -0,0 +1,55 @@ |
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { |
||||
|
||||
var Controller = { |
||||
index: function () { |
||||
// 初始化表格参数配置
|
||||
Table.api.init({ |
||||
extend: { |
||||
index_url: 'notice/index' + location.search, |
||||
add_url: 'notice/add', |
||||
edit_url: 'notice/edit', |
||||
del_url: 'notice/del', |
||||
multi_url: 'notice/multi', |
||||
import_url: 'notice/import', |
||||
table: 'notice', |
||||
} |
||||
}); |
||||
|
||||
var table = $("#table"); |
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({ |
||||
url: $.fn.bootstrapTable.defaults.extend.index_url, |
||||
pk: 'id', |
||||
sortName: 'id', |
||||
columns: [ |
||||
[ |
||||
{checkbox: true}, |
||||
{field: 'id', title: __('Id')}, |
||||
{field: 'title', title: __('Title'), operate: 'LIKE'}, |
||||
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, |
||||
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status}, |
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
||||
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
||||
] |
||||
] |
||||
}); |
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table); |
||||
}, |
||||
add: function () { |
||||
Controller.api.bindevent(); |
||||
}, |
||||
edit: function () { |
||||
Controller.api.bindevent(); |
||||
}, |
||||
api: { |
||||
bindevent: function () { |
||||
Form.api.bindevent($("form[role=form]")); |
||||
} |
||||
} |
||||
}; |
||||
return Controller; |
||||
}); |
Loading…
Reference in new issue