119 lines
4.9 KiB
JavaScript
119 lines
4.9 KiB
JavaScript
define(['table', 'upload','form'], function (Table,Upload,Form) {
|
|
var User = {
|
|
//Do setup work hereAction
|
|
index: function () {
|
|
window.filterData = {
|
|
};
|
|
window.statusOption = Config.statusList;
|
|
window.typeOption = Config.typeList;
|
|
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: '/app/admin/xuanchuan/select',
|
|
add_url: '/app/admin/xuanchuan/insert',
|
|
edit_url: '/app/admin/xuanchuan/update',
|
|
del_url: '/app/admin/xuanchuan/delete',
|
|
multi_url: '/app/admin/xuanchuan/multi',
|
|
dragsort_url: '/app/admin/xuanchuan/weigh',
|
|
table: 'user_xuanchuan',
|
|
}
|
|
});
|
|
|
|
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",
|
|
formatter:function(v,row){
|
|
for (let i = 0; i < Config.typeList.length; i++) {
|
|
if(Config.typeList[i].value == v){
|
|
return Config.typeList[i].label;
|
|
}
|
|
}
|
|
return '';
|
|
},
|
|
filter: "select",
|
|
filterOption:"groupOption",
|
|
visible: false,
|
|
},
|
|
{
|
|
title: "用户",
|
|
field: "user_id",
|
|
formatter:function(v,row){
|
|
return row.user.username;
|
|
},
|
|
visible: false,
|
|
},
|
|
{
|
|
title: "图片",
|
|
field: "files",
|
|
// formatter:Table.api.formatter.images,
|
|
// operate:Table.api.events.image
|
|
formatter:function(v){
|
|
var html='<ul class="list-inline clearfix lyear-uploads-pic">';
|
|
v=v.split(',');
|
|
for (let i = 0; i < v.length; i++) {
|
|
html+= '<li class="col-xs-4 col-sm-3 col-md-2 previewitem">'
|
|
+' <figure class="btn-preview">'
|
|
+' <img src="'+Fast.api.cdnurl(v[i])+'" width="120" data-url="'+Fast.api.cdnurl(v[i])+'" alt="图片一" class="img-sm img-center img-responsive">'
|
|
+' </figure>'
|
|
+'</li>';
|
|
}
|
|
return html+'</ul>';
|
|
}
|
|
},
|
|
{
|
|
title: "创建时间",
|
|
field: "created_at"
|
|
},
|
|
{
|
|
title: "更新时间",
|
|
field: "updated_at",
|
|
formatter:Table.api.formatter.datetime,
|
|
visible: false,
|
|
},
|
|
{
|
|
title: "状态",
|
|
field: "status",
|
|
formatter: Table.api.formatter.switch,
|
|
filter:'select',
|
|
filterOption:'statusOption'
|
|
},
|
|
{
|
|
field: 'operate', title: '操作',
|
|
table: table, events: Table.api.events.operate,
|
|
formatter: Table.api.formatter.operate
|
|
}
|
|
]
|
|
]
|
|
};
|
|
// 初始化表格
|
|
table.bootstrapTable(tableOptions);
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
update:function(){
|
|
var form = $('form');
|
|
Form.api.bindevent(form);
|
|
},
|
|
insert:function(){
|
|
var form = $('form');
|
|
Form.api.bindevent(form);
|
|
}
|
|
};
|
|
return User
|
|
}); |