mirror of https://gitee.com/karson/fastadmin.git
分类管理新新增加按类型进行筛选的功能。
parent
c06a108f1b
commit
30bc867ed5
|
|
@ -46,22 +46,33 @@ class Category extends Backend
|
|||
if ($this->request->isAjax())
|
||||
{
|
||||
$search = $this->request->request("search");
|
||||
$type = $this->request->request("type");
|
||||
|
||||
//构造父类select列表选项数据
|
||||
$list = [];
|
||||
if ($search)
|
||||
{
|
||||
|
||||
foreach ($this->categorylist as $k => $v)
|
||||
{
|
||||
if (stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false)
|
||||
{
|
||||
$list[] = $v;
|
||||
if ($search) {
|
||||
if ($v['type'] == $type && stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false)
|
||||
{
|
||||
if($type == "all" || $type == null) {
|
||||
$list = $this->categorylist;
|
||||
} else {
|
||||
$list[] = $v;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if($type == "all" || $type == null) {
|
||||
$list = $this->categorylist;
|
||||
} else if ($v['type'] == $type){
|
||||
$list[] = $v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$list = $this->categorylist;
|
||||
}
|
||||
|
||||
$total = count($list);
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
<div class="panel-heading">
|
||||
{:build_heading()}
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="all" data-toggle="tab">全部</a></li>
|
||||
{foreach name="typeList" item="vo"}
|
||||
<li><a href="{$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">
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
var table = $("#table");
|
||||
var tableOptions = {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
escape: false,
|
||||
pk: 'id',
|
||||
|
|
@ -39,10 +38,33 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
};
|
||||
// 初始化表格
|
||||
table.bootstrapTable(tableOptions);
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
//绑定TAB事件
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
// var options = table.bootstrapTable(tableOptions);
|
||||
var typeStr = $(this).attr("href");
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
options.pageNumber = 1;
|
||||
options.queryParams = function (params) {
|
||||
// params.filter = JSON.stringify({type: typeStr});
|
||||
params.type = typeStr;
|
||||
|
||||
return params;
|
||||
};
|
||||
table.bootstrapTable('refresh', {});
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
//必须默认触发shown.bs.tab事件
|
||||
// $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
|
||||
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
|
|
|
|||
Loading…
Reference in New Issue