Files
im/plugin/admin/public/js/xuanchuan.js
T
2025-12-24 16:59:05 +08:00

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: 'xuanchuan/select',
add_url: 'xuanchuan/insert',
edit_url: 'xuanchuan/update',
del_url: 'xuanchuan/delete',
multi_url: 'xuanchuan/multi',
dragsort_url: '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
});