mirror of https://gitee.com/karson/fastadmin.git
86 lines
4.1 KiB
JavaScript
86 lines
4.1 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'posts/page/index',
|
|
add_url: 'posts/page/add',
|
|
edit_url: 'posts/page/edit',
|
|
del_url: 'posts/page/del',
|
|
multi_url: 'posts/page/multi',
|
|
table: 'page',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
sortName: 'weigh',
|
|
columns: [
|
|
[
|
|
{field: 'state', checkbox: true},
|
|
{field: 'id', title: __('Id'), operate: false},
|
|
{field: 'site_id', title: __('Site_id'),
|
|
formatter: function (value, row, index) {
|
|
return row.sites==null?'':'<a href="javascript:;" class="searchit" data-field="site_id" data-value="' + row.site_id + '">' + row.sites.name + '</a>';
|
|
},visible:Config.show_sitename},
|
|
{field: 'title', title: __('Title'), align:'left', operate: 'LIKE %...%', placeholder: '关键字,模糊搜索',
|
|
formatter: function(value,row,index){
|
|
return value + (row.image==''?'' : ' <span><i class="fa fa-file-image-o text-danger"></i></span>');
|
|
}
|
|
},
|
|
{field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag, operate: false},
|
|
{field: 'lang', title: __('lang'), operate: false,
|
|
formatter: function(value,row,index){
|
|
return __(value);
|
|
}
|
|
},
|
|
{field: 'views', title: __('Views'), operate: false},
|
|
//{field: 'comments', title: __('Comments'), operate: false},
|
|
{field: 'weigh', title: __('Weigh'), operate: false},
|
|
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {'normal': __('Normal'), 'hidden': __('Hidden')}, style: 'min-width:100px;'},
|
|
{field: 'createtime', title: __('Create Time'), formatter: Table.api.formatter.datetime, operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"'},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
|
]
|
|
],
|
|
//普通搜索
|
|
commonSearch: true,
|
|
titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
add: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
$(document).on("change", "#c-site_id", function () {
|
|
siteid=$(this).val();
|
|
$('.plupload').data("siteid", siteid);
|
|
$('.fachoose').data("siteid", siteid);
|
|
Fast.api.ajax({url: 'posts/sites/get_site_langs', data: {"lang": siteid}}, function (r,data) {
|
|
$("#language_choose").html(data.html);
|
|
Form.api.bindevent($("#language_choose"));
|
|
return false;
|
|
});
|
|
});
|
|
|
|
|
|
$('.plupload').data("siteid", $("#c-site_id").val());
|
|
$('.fachoose').data("siteid", $("#c-site_id").val());
|
|
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
}); |