var $fileTable = $('#file-table').bootstrapTable('destroy').bootstrapTable({
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
url: '',
method: 'GET',
dataType: "json",
uniqueId: 'id',
striped: false,
cache: false,
sortName: 'upload_time',
sortable: true,
sortOrder: 'desc',
sidePagination: "server",
undefinedText: '--',
singleSelect: true,
//showRefresh: true,
//showColumns: true,
//toolbar: '#file-table-toolbar',
search: false,
strictSearch: true,
clickToSelect: false,
pagination: true,
pageNumber: 1,
pageSize: 10,
pageList: [5, 10, 20],
paginationPreText: "上一页",
paginationNextText: "下一页",
//showToggle: true,
//cardView: false,
//detailView: false,
//showPaginationSwitch: true,
queryParamsType: "",
queryParams: function (params) {
var temp = {
'pageSize': params.pageSize,
'pageNumber': clickByDirOrPageButton === 1 ? 1 : params.pageNumber,
'searchText': searchTextParam,
'sortName': params.sortName,
'sortOrder': params.sortOrder,
'file_id': file_id
};
thisPage = params.pageNumber;
thisPageSize = params.pageSize;
return temp;
},
columns: [
{
checkbox: true
},
{
title: '序号',
width: 60,
formatter: function (value, row, index) {
return index + 1;
}
},
{
field: 'name',
title: '名称',
sortable: true,
formatter: function (value, row, index) {
if (row.uploaded) {
return `<a onclick="openFileInfo()" href="#">${value}</a>`;
} else {
return value;
}
}
},
{
field: 'status',
title: '状态',
width: 100
}, {
field: 'create_time',
title: '创建时间',
sortable: true,
width: 240
}, {
field: 'update_time',
title: '更新时间',
sortable: true,
width: 240
}, {
title: '操作',
width: 60,
formatter: function (value, row, index) {
var r = JSON.stringify(row);
return `<span class="glyphicon glyphicon-pencil" aria-hidden="true" style="cursor: pointer;" onclick='editTask(${r})'></span>`
}
}
],
onLoadSuccess: function () {
//alert('表格加载成功!');
},
onLoadError: function () {
toastr.error("数据加载失败!", "错误提示");
},
onClickedRow: function (row, $element) {
var id = row.id;
},
onClickRow: function (row, $element) {
}
});
$("#hide-column-button").click(function(){
$fileTable.bootstrapTable('hideColumn', 'update_time');
})
$("#show-column-button").click(function(){
$fileTable.bootstrapTable('showColumn', 'update_time');
})