1
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
define(['table', 'upload','form'], function (Table,Upload,Form) {
|
||||
var User = {
|
||||
//Do setup work hereAction
|
||||
index: function () {
|
||||
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: '/app/admin/category/select',
|
||||
add_url: '/app/admin/category/insert',
|
||||
edit_url: '/app/admin/category/update',
|
||||
del_url: '/app/admin/category/delete',
|
||||
multi_url: '/app/admin/category/multi',
|
||||
dragsort_url: '/app/admin/category/weigh',
|
||||
table: 'category',
|
||||
}
|
||||
});
|
||||
var categorytype = [];
|
||||
for (const key in Config.categorytype) {
|
||||
categorytype.push({
|
||||
label:Config.categorytype[key],
|
||||
value:key
|
||||
});
|
||||
}
|
||||
window.categorytype = categorytype;
|
||||
|
||||
var table = $("#table");
|
||||
var tableOptions = {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
commonSearch: false,
|
||||
search: false,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
filter: "number",
|
||||
sortable: true // 是否排序
|
||||
},
|
||||
{
|
||||
title: "类型",
|
||||
field: "type",
|
||||
filter: "select",
|
||||
filterOption: "categorytype",
|
||||
formatter:function(v,d){
|
||||
return '<label class="label label-primary">'+(Config.categorytype[v] || v) +'</label>';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "标志",
|
||||
field: "name",
|
||||
filter: "string",
|
||||
},
|
||||
{
|
||||
title: "标题",
|
||||
field: "title",
|
||||
filter: "string",
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
field: "status",
|
||||
formatter: Table.api.formatter.switch
|
||||
},
|
||||
{field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
};
|
||||
// 初始化表格
|
||||
table.bootstrapTable(tableOptions);
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
update:function(){
|
||||
Config['uploadurl'] = '/app/admin/attachment/avatar';
|
||||
var form = $('form');
|
||||
Form.api.bindevent(form)
|
||||
},
|
||||
insert:function(){
|
||||
Config['uploadurl'] = '/app/admin/attachment/avatar';
|
||||
var form = $('form');
|
||||
Form.api.bindevent(form)
|
||||
}
|
||||
};
|
||||
return User
|
||||
});
|
||||
Reference in New Issue
Block a user