function renderIssueTable(){
$('#issueTable').bootstrapTable({
detailView: false,//父子表
//分页方式:client 客户端分页,server服务端分页(*)
sidePagination: "client",
pageNumber: 1,
pageSize: 50,
pageList: [50, 100, 200, 300],
paginationHAlign: 'right', //right, left
paginationVAlign: 'bottom', //bottom, top, both
paginationDetailHAlign: 'left', //right, left
paginationPreText: '‹',
paginationNextText: '›',
searchOnEnterKey: false,
strictSearch: false,
searchAlign: 'right',
selectItemName: 'btSelectItem',
//是否显示搜索
search: true,
url: 'listIssueOfRecent6Month',
method: 'GET',
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
paginationLoop: false,
silent: true,
//是否启用排序
sortable: true,
sortName: 'deptName',
//排序方式
sortOrder: "asc",
contentType: 'application/json',
dataType: 'json',
// dataField: 'departmentIssueQualityDataList', //server 后端 : json 对应的表格数据 key
responseHandler: function (res) {
console.log(res)
$('#issueTable').bootstrapTable('getOptions').data = res.result;
return res;
},
// 缺陷创建时间(年月日)、缺陷ID、缺陷解决者、项目名称、所属产品线、深度、reopen次数、缺陷修复时长(取fixed_duration )、严重程度、缺陷状态、缺陷标题
columns: [
{
title: 'ID',
field: 'aoneIssueId',
align: 'left',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
var url = `https://aone.com/issue/${value}`;
return `<a href="${url}" target="_blank">${value}</a>`;
}
},
{
title: '标题',
field: 'subject',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
return value;
}
},
{
title: '状态',
field: 'status',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
return value;
}
},
{
title: '项目',
field: 'aoneProjectId',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
var url = `https://aone.com/project/${value}`;
return `<a href="${url}" target="_blank">${value}</a>`;
}
},
{
title: '产品线',
field: 'aoneProductId',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
var url = `https://aone.com/project/${value}`;
return `<a href="${url}" target="_blank">${value}</a>`;
}
},
{
title: '修复时长(天)',
field: 'fixedDuration',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
if (value && value !== 0) {
value = (value/(60*60*24)).toFixed(2)
}
return value;
}
},
{
title: '解决者',
field: 'assignedToWorkno',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
var url = `https://aone.com/${value}`;
return `<a href="${url}" target="_blank">${value}</a>`;
}
}, {
title: '严重程度',
field: 'seriousLevel',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
return value;
}
}, {
title: 'reopen次数',
field: 'reopenTimes',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
return value
}
}, {
title: '发现深度',
field: 'depth',
align: 'center',
valign: 'middle',
sortable : true,
formatter: (value, row, index) => {
return value
}
}, {
title: '部门',
field: 'deptFullName',
align: 'center',
valign: 'middle',
sortable : true,
cellStyle: function (value, row, index) {
return {
css: {
"min-width": "100px",
"word-wrap": "break-word",
"word-break": "normal"
}
};
},
formatter: (value, row, index) => {
return value
}
}
],
queryParams: function (params) {
params.deptNo = $("#searchDept").select2("val");
return params
},
// 当表格加载完毕才可以绑定的事件
onPostBody: (rows) => {
}
});
$('#issueTable').bootstrapTable('refresh');
}
参考文档:
http://bootstrap-table.wenzhixin.net.cn/