欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

columns数组形式展示不同列数据

程序员文章站 2022-10-31 09:12:21
function workList() { var status = $("#status1").val(); if (null == status || status == "") { status = $("select[name='status']").val(); } var workSta ......
function worklist() {
var status = $("#status1").val();
if (null == status || status == "") {
status = $("select[name='status']").val();
}
var workstatus;
switch (status) {
case '1'://待办
workstatus = [
{
field: 'id111',
width: 60,
title: "序号",
align: 'center',
formatter: function (value, row, index) {
return index + 1;
}
},
{
field: 'title',
title: '任务名称',
width: 300,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '" >' + value + '</span>';
return [nameicon].join('');
},
events: {
'click .edit': function (e, value, row, index) {
waitviewtask(row.id);
}
}
},
{
field: 'zrrname',
title: '责任人',
align: 'center',
width: 100,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '">' + value + '</span>';
return [nameicon].join('');
},
},

{
field: 'xbrname',
align: 'center',
title: '协办人',
width: 100,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '">' + value + '</span>';
return [nameicon].join('');
},
},
{
field: 'leadername',
title: '分管领导',
align: 'center',
width: 100,
},
{
field: 'startdate',
title: '交办日期',
align: 'center',
sortable: true,
order: 'desc',
width: 120
}, {
field: 'duedate',
title: '完成日期',
align: 'center',
sortable: true,
order: 'desc',
width: 120
},
{
field: 'operator2',
title: '操作',
align: 'center',
valign: 'middle',
searchable: false,
clicktoselect: false,
width: 200,
formatter: function (value, row, index) {
var planicon = '';
if (!!row && row.length > 0) {
for (var i = 0; i < row.length; i++) {
var user = row[i];
if (!!user && user.personneltype === '2') {
if ($("#nowuserid").val() === user.user.id) {
planicon = '<div align="center"><span class="planicon cursorpointer" data-toggle="modal" >【计划】</span>';
break;
}
}
}
}
var editicon = '<span class="editicon cursorpointer">【工作办理】</span></div>';
return [planicon, editicon].join('');
},
events: {
'click .editicon': function (e, value, row, index) {
waitviewtask(row.id);
},
'click .planicon': function (e, value, row, index) {
jihua(row);
}
}
}
];
break;
case '2'://超期
workstatus = [{
field: 'id',
title: 'id',
visible: false
},
{
field: 'id111',
width: 60,
title: "序号",
visible: true,
align: 'center',
formatter: function (value, row, index) {
return index + 1;
}
},
{
field: 'title',
title: '任务名称',
// align:'center',
width: 220,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '" >' + value + '</span>';
return [nameicon].join('');
},
events: {
'click .edit': function (e, value, row, index) {
timeoutviewtask(row.id)
},
}
},
{
field: 'zrrname',
title: '责任人',
align: 'center',
width: 80,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '">' + value + '</span>';
return [nameicon].join('');
},
},
{
field: 'xbrname',
title: '协办人',
align: 'center',
width: 80,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '">' + value + '</span>';
return [nameicon].join('');
},
},
{
field: 'leadername',
title: '分管领导',
align: 'center',
width: 70
},
{
field: 'startdate',
title: '交办日期',
align: 'center',
sortable: true,
order: 'desc',
width: 80
},
{
field: 'duedate',
title: '完成日期',
align: 'center',
sortable: true,
order: 'desc',
width: 80
}
,
/* {
field: 'betweenday',
title: '超期天数',
align: 'center',
width: 80,
sortable: true,
order: 'desc',
},*/
{
field: 'status',
title: '状态',
align: 'center',
//valign: 'middle',
width: 60,
formatter: function (value, row, index) {
if (value == '2') {
var nameicon = '<span style="width:14px;height:14px;border-radius: 50%;display:inline-block;margin-right:10px" class="edit cursorpointer" title="已超期"></span>';
return '<span></span>' + [nameicon].join('');
} else if (value == '1') {
var nameicon = '<span style="width:14px;height:14px;border-radius: 50%;display:inline-block;margin-right:10px" class="edit cursorpointer" title="进行中"></span>';
return '<span></span>' + [nameicon].join('');
} else if (value == '0') {
var nameicon = '<span style="width:14px;height:14px;border-radius: 50%;display:inline-block;margin-right:10px" class="edit cursorpointer" title="暂存"></span>';
return '<span></span>' + [nameicon].join('');
} else if (value == '3' || value == '4') {
var nameicon = '<span style="width:14px;height:14px;border-radius: 50%;display:inline-block;margin-right:10px" class="edit cursorpointer" title="已办结"></span>';
return '<span></span>' + [nameicon].join('');
}
return "-";
}
},
{
field: 'operator2',
title: '操作',
align: 'center',
valign: 'middle',
searchable: false,
clicktoselect: false,
width: 100,
formatter: function (value, row, index) {
var editicon = '<span class="editicon cursorpointer">【工作办理】</span></div>';
return [editicon].join('');
},
events: {
'click .editicon': function (e, value, row, index) {
selectthing(row);
},
'click .delayicon': function (e, value, row, index) {
if (row.ifdelay == '1') {
layer.msg("您已经申请延期,正在等待审核。。")
} else {
selectthing(row);
}
},
'click .endicon': function (e, value, row, index) {
selectthing(row);
}
}
}
];
break;
case '5'://已办结
workstatus = [{
checkbox: true,
visible: false
},
{
field: 'id111',
width: 45,
title: "序号",
align: 'center',
formatter: function (value, row, index) {
return index + 1;
}
},
{
field: 'title',
title: '任务名称',
// align:'center',
width: 220,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '" >' + value + '</span>';
return [nameicon].join('');
},
events: {
'click .edit': function (e, value, row, index) {
completedviewtask(row.id)
},
}
},
{
field: 'zrrname',
title: '责任人',
align: 'center',
width: 70,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '">' + value + '</span>';
return [nameicon].join('');
},
}, {
field: 'xbrname',
title: '协办人',
align: 'center',
width: 70,
formatter: function (value, row, index) {
var nameicon = '<span class="edit cursorpointer" title="' + value + '">' + value + '</span>';
return [nameicon].join('');
}
},
{
field: 'leadername',
title: '分管领导',
align: 'center',
width: 70
},
{
field: 'startdate',
title: '交办日期',
align: 'center',
sortable: true,
order: 'desc',
width: 80
},
{
field: 'duedate',
title: '完成日期',
align: 'center',
sortable: true,
order: 'desc',
width: 80
},
{
field: 'eduedate',
title: '实际办结时间',
align: 'center',
width: 90,
sortable: true,
order: 'desc',
},
/* {
field: 'betweenday',
title: '超期天数',
align: 'center',
width: 80,
sortable: true,
order: 'desc',
},*/
{
field: 'status',
title: '状态',
align: 'center',
sortable: true,
order: 'desc',
// valign: 'middle',
width: 60,
formatter: function (value, row, index) {
if (value == '2') {
var nameicon = '<span style="width:14px;height:14px;border-radius: 50%;display:inline-block;margin-right:10px" class="edit cursorpointer" title="已超期"></span>';
return '<span></span>' + [nameicon].join('');
} else if (value == '1') {
var nameicon = '<span style="width:14px;height:14px;border-radius: 50%;display:inline-block;margin-right:10px" class="edit cursorpointer" title="进行中"></span>';
return '<span></span>' + [nameicon].join('');
} else if (value == '0') {
var nameicon = '<span style="width:14px;height:14px;border-radius: 50%;display:inline-block;margin-right:10px" class="edit cursorpointer" title="暂存"></span>';
return '<span></span>' + [nameicon].join('');
} else if (value == '3' || value == '4') {
var nameicon = '<span style="width:14px;height:14px;border-radius: 50%;display:inline-block;margin-right:10px" class="edit cursorpointer" title="已办结"></span>';
return '<span></span>' + [nameicon].join('');
}
return "-";
}
}
];
break;
}
console.log("进来我的工作")
$("#worklistform")[0].reset();
$('#worklist').bootstraptable({//待办任务worklist
method: 'post',
url: 'v2/mywork/workdatelist',
silent: true,
cache: false,
pagination: true,
height: window.bstableheight - 70,
contenttype: 'application/x-www-form-urlencoded',
showheader: true,//是否显示列头。
pagesize: 10, //每页的记录行数(*)
pagelist: [10, 20, 30, 40], //可供选择的每页的行数(*)
showcolumns: false,//是否显示内容列下拉框。
clicktoselect: true,//设置 true 将在点击行时,自动选择 rediobox 和 checkbox。?
sidepagination: 'server',//设置在哪里进行分页,可选值为 'client' 或者 'server'。设置 'server'时,必须设置服务器数据地址(url)或者重写ajax方法。
sortorder: 'desc',
sortname: 'startdate',
queryparams: searchparam,
singleselect: true,
responsehandler: function (data) {
data = fastjson.format(data);
return data;
},
columns: workstatus,
});
}