作者 开飞机的舒克

后台优化

... ... @@ -22,7 +22,7 @@ class Banner extends Backend
{
parent::_initialize();
$this->model = new \app\admin\model\Banner;
$this->view->assign("isUrlList", $this->model->getIsUrlList());
}
... ... @@ -51,12 +51,14 @@ class Banner extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','title','images','is_url','url','details','createtime']);
$row->visible(['id','title','images','details','createtime']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
... ...
... ... @@ -3,10 +3,6 @@
return [
'Title' => '轮播图名称',
'Images' => '轮播图',
'Is_url' => '是否为链接',
'Is_url 0' => '否',
'Is_url 1' => '是',
'Url' => '跳转地址',
'Details' => '轮播图内容',
'Createtime' => '创建时间',
'Updatetime' => '修改时间'
... ...
... ... @@ -8,6 +8,10 @@ use think\Model;
class Banner extends Model
{
// 表名
protected $name = 'banner';
... ... @@ -21,21 +25,16 @@ class Banner extends Model
// 追加属性
protected $append = [
'is_url_text'
];
public function getIsUrlList()
{
return ['0' => __('Is_url 0'), '1' => __('Is_url 1')];
}
public function getIsUrlTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['is_url']) ? $data['is_url'] : '');
$list = $this->getIsUrlList();
return isset($list[$value]) ? $list[$value] : '';
}
}
... ...
... ... @@ -21,36 +21,11 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Is_url')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-is_url" class="form-control selectpicker" name="row[is_url]">
{foreach name="isUrlList" item="vo"}
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
{/foreach}
</select>
<textarea id="c-details" class="form-control " rows="5" name="row[details]" cols="50"></textarea>
</div>
</div>
{switch name="isUrl"}
{case value="1"}
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Url')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-url" class="form-control" name="row[url]" type="text">
</div>
</div>
{/case}
{case value="0"}
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-details" class="form-control editor" rows="5" name="row[details]" cols="50"></textarea>
</div>
</div>
{/case}
{/switch}
<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">
... ...
... ... @@ -21,24 +21,6 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Is_url')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-is_url" class="form-control selectpicker" name="row[is_url]">
{foreach name="isUrlList" item="vo"}
<option value="{$key}" {in name="key" value="$row.is_url"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Url')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-url" class="form-control" name="row[url]" type="text" value="{$row.url|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-details" class="form-control " rows="5" name="row[details]" cols="50">{$row.details|htmlentities}</textarea>
... ...
... ... @@ -8,10 +8,13 @@
<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('banner/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('banner/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('banner/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<div class="dropdown btn-group {:$auth->check('banner/multi')?'':'hide'}">
<ul class="dropdown-menu text-left" role="menu">
<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">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
... ...
... ... @@ -22,21 +22,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
showToggle: false,//浏览模式功能关闭
showColumns: false,//显示隐藏列功能关闭
//commonSearch: false, //关闭通用搜索按钮
showExport: false,//导出功能关闭
clickToSelect: false, //是否启用点击选中
dblClickToEdit: false, //是否启用双击编辑
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'is_url_text', title: __('Is_url'), searchList: {"0":__('Is_url 0'),"1":__('Is_url 1')}},
{field: 'url', title: __('Url'), operate: 'LIKE', formatter: Table.api.formatter.url},
// {field: 'details',title: '详情'},
{field: 'details', title: __('Details'), operate: false,
formatter : function(value, row, index, field){
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.details + "'>" + value + "</span>";
},
cellStyle : function(value, row, index, field) {
return {
css: {
"white-space": "nowrap",
"text-overflow": "ellipsis",
"overflow": "hidden",
"max-width": "150px"
}
};
}},
{field: 'createtime', title: __('Createtime'), 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}
]
... ...