$(function () {
//$('#table').attr("data-url", "/conference/" + location.href.split("audit/")[1] + "/audits");
var count = 0;
var fmtIdx = function (value, row, index) {
return index;
}; $('.btn-excel').on('click', function() {
window.location.href= '/conference/auditExcel/' + location.href.split("/")[5];
}); $.ajax({
type: "GET",
url: "/conference/" + location.href.split("audit/")[1] + "/audits",
async:true,
dataType: "json",
success: function (data,columns) {
var columns = [{
field: 'state',
checkbox: true,
formatter:stateFormatter
}, {
field: 'audit_name',
title: '用户名'
}, {
field: 'audit_mobile',
title: '手机'
}, {
field: 'audit_status',
title: '审核状态',
formatter: statusFormatter,
events: actionEvents
}, {
field: 'audit_msg_status',
title: '短信发送状态',
formatter: msgStausFormatter
}
]; if(data.length!==0){
for(var p in data[0]){
if(['state','audit_name','audit_mobile','audit_status','audit_msg_status','audit_id','conf_id','user_id'].indexOf(p)==-1){
columns.push({ field:p,title:p});
}
}
} (function(columns){ $('#table').bootstrapTable('destroy').bootstrapTable({
method: 'get',
url: "/conference/" + location.href.split("audit/")[1] + "/audits",
cache: false,
striped: true,
sidePagination: 'client', // client or server
pageNumber: 1,
pageSize: 10,
pageList: [10,20,30],
paginationHAlign: 'right', //right, left
paginationVAlign: 'bottom', //bottom, top, both
sortable:false,
search: true,
showColumns: true,
showPaginationSwitch: true,
showRefresh: true,
clickToSelect: true,
responseHandler: function (res) {
console.log(res);
var len = res.length;
for(var i=0;i<len;i++){
res[i].index = i;
}
return res;
},
columns:columns
});
})(columns);
}
}); function topwvalid() {
$('#res').attr('action', 'respw').submit();
}
}); window.actionEvents = {
'click .pass' : function (e, value, row, index) {
audit(1,row,index);
},
'click .nopass' : function (e, value, row, index) {
audit(2,row,index);
}
} //审核提交
function audit(status, row ,index) {
$.ajax({
type: "PUT",
url: "/conference/audit",
data: {
audit_id: row.audit_id,
audit_status: status
},
dataType: "json",
success: function (data) {
console.log(data);
row.audit_status = status;
$('table').bootstrapTable('updateRow',{
index:index,
row:row
}
);
}
});
} //批量审核
function sign(status){
var list = $('#table').bootstrapTable('getSelections');
var len = list.length; count = 0;
for(var i=0;i<len;i++){
(function(i){ $.ajax({
type: "PUT",
url: "/conference/audit",
data: {
audit_id: list[i].audit_id,
audit_status: status,
},
dataType: "json",
success: function (data) {
if(data.RS_CODE==0){
list[i].audit_status =status;
count++;
if(i===len-1){
$('#table').bootstrapTable('updateRow',{index:list[i].index,row:list[i]});
$('#alllowNum').text((~~$('#alllowNum').text()+count));
}
}else{
console.log(data.RS_MSG);
}
}
}); })(i); }
} //checkbox 格式化
function stateFormatter(value, row) {
if(row.audit_status==1||row.audit_status==2){
return {
disabled: true
};
}
return value;
} //状态格式化
function statusFormatter(value, row) {
if (value == 0) {
return "<button type='button' class='btn btn-primary btn-xs pass'>通过</button>"+
"<button type='button' class='btn btn-primary btn-xs nopass' style='margin-left:20px;'>拒绝通过</button>";
} else if(value == 1) {
return "<span class='pass'>已通过</span>";
}else {
return "<span class='red'>已拒绝</span>";
}
} //短信状态格式化
function msgStausFormatter(value) {
if (value == 0) {
return "未发送";
} else if(value == 1) {
return "已发送";
}else {
return "发送失败";
}
}
/*<form action="" method="post" id="res">
<input type="hidden" name="confId" id="confId" value="${confdata.confId}">
<input type="hidden" name="respw" id="respw" value="${respw}"> </form>*/