1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
| $(function () {
$('#table1').bootstrapTable({ url: '/user/queryuser', method:"get", totalField:"num", dataField:"list", classes: "table table-bordered table-striped", toolbar:"#toolbar", pagination: true, sidePagination: "client", pageNumber:1, pageSize: 5, pageList: [10, 25, 50, 100], showRefresh: true, search: true, searchOnEnterKey:false, showColumns: true, clickToSelect: true, singleSelect:"true", uniqueId: "userCode", showToggle:true, showFullscreen:true, showExport: true, exportDataType: $(this).val(), exportTypes: ['json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'xlsx', 'pdf'], exportOptions: { fileName: 'TableUser', }, dataType:"text", responseHandler:function(res) { return JSON.parse(res); }, columns: [{
checkbox:true, align:"center", },{ title: '排序', align: "center", formatter: function (value, row, index) { return index + 1; } },{ field: 'userName', title: '姓名', align:"center", }, { field: 'userCode', title: '用户名', align:"center", }, { field: 'gender', title: '性别', align:"center", formatter:function (value,row,index) { if (value == 1){ return "男" }else{ return "女" } }
}, { field: 'birthday', title: '出生日期', align:"center", formatter: function (value, row, index) { return changeDateFormat(value) }, sortable: true, },{ field:"userCode", title: "操作", width:"210", align:"center", valign:"middle", formatter:actionFormatter, }] }); });
function actionFormatter(value) { var result = ""; var id = value+""; result += "<a onclick=\"query('"+value+"')\" href='javascript:;' class='btn btn-xs green' title='查看'><span class='glyphicon glyphicon-search'>查看</span></a>"; result += "<a onclick=\"upData('"+value+"')\" href='javascript:;' class='btn btn-xs blue' title='编辑'><span class='glyphicon glyphicon-pencil' data-target='#upData'>编辑</span></a>"; result += "<a onclick=\"del('"+value+"')\" href='javascript:;' class='btn btn-xs red' title='删除'><span class='glyphicon glyphicon-remove'>删除</span></a>"; return result; } function query(value){ console.log("数据id为"+value+"正在查看信息") } function upData(value){ console.log("数据id为"+value+"正在编辑信息") } function del(value){ console.log("数据id为"+value+"正在删除信息") }
function changeDateFormat(cellval) { var dateVal = cellval + ""; if (cellval != null) { var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10)); var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + seconds; } }
function exportData(){ $('#table').tableExport({ type: 'excel', exportDataType: "all", ignoreColumn: [0], fileName: 'Tablexxx', onCellHtmlData: function (cell, row, col, data){ console.info(data); return data; }, }); }
|