You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
4.9 KiB
95 lines
4.9 KiB
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'research/index/index' + location.search,
|
|
add_url: 'research/index/add',
|
|
edit_url: 'research/index/edit',
|
|
del_url: 'research/index/del',
|
|
multi_url: 'research/index/multi',
|
|
import_url: 'research/index/import',
|
|
table: 'research',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
fixedColumns: true,
|
|
fixedRightNumber: 1,
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'id', title: __('Id')},
|
|
{field: 'author_ids_text', title: __('Author'), operate: false},
|
|
{field: 'author.name', title: __('Author'), operate: 'LIKE',visible:false},
|
|
// {field: 'topic_ids', title: __('Topic_ids'), operate: 'LIKE'},
|
|
{field: 'topic.title', title: __('Topic'), operate: 'LIKE',visible:false},
|
|
{field: 'topic_ids_text', title: __('Topic'), operate: false},
|
|
{field: 'tag', title: __('Tag'), operate: 'LIKE', formatter: Table.api.formatter.flag},
|
|
{field: 'cover_image', title: __('Cover'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
|
{field: 'title', title: __('Title'), operate: 'LIKE'},
|
|
// {field: 'description', title: __('Description'), operate: 'LIKE'},
|
|
{field: 'publishedtime', title: __('Published Date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
{field: 'views', title: __('Views')},
|
|
{field: 'status', title: __('Status'), searchList: {"Live":__('Live'),"Scheduled":__('Scheduled'),"Delisted":__('Delisted')}, formatter: Table.api.formatter.status},
|
|
{field: 'sort', title: __('Sort')},
|
|
{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: 'publishedtime', title: __('Publishedtime'), 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}
|
|
{
|
|
field: 'operate',
|
|
width: "150px",
|
|
title: __('Operate'),
|
|
table: table,
|
|
events: Table.api.events.operate,
|
|
buttons: [
|
|
{
|
|
name: 'ajax',
|
|
title: __('Sync Medium'),
|
|
classname: 'btn btn-xs btn-warning btn-ajax',
|
|
icon: 'fa fa-leaf',
|
|
url: 'research/index/syncMedium',
|
|
success: function (data, ret) {
|
|
Layer.alert(ret.msg);
|
|
return false;
|
|
},
|
|
error: function (data, ret) {
|
|
console.log(data, ret);
|
|
Layer.alert(ret.msg);
|
|
return false;
|
|
}
|
|
},
|
|
],
|
|
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;
|
|
});
|