我的bootstrapTable的应用
$(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>*/
我的bootstrapTable的应用的更多相关文章
- JS组件系列——BootstrapTable+KnockoutJS实现增删改查解决方案(一)
前言:出于某种原因,需要学习下Knockout.js,这个组件很早前听说过,但一直没尝试使用,这两天学习了下,觉得它真心不错,双向绑定的机制简直太爽了.今天打算结合bootstrapTable和Kno ...
- JS组件系列——BootstrapTable 行内编辑解决方案:x-editable
前言:之前介绍bootstrapTable组件的时候有提到它的行内编辑功能,只不过为了展示功能,将此一笔带过了,罪过罪过!最近项目里面还是打算将行内编辑用起来,于是再次研究了下x-editable组件 ...
- JS组件系列——BootstrapTable+KnockoutJS实现增删改查解决方案(四):自定义T4模板快速生成页面
前言:上篇介绍了下ko增删改查的封装,确实节省了大量的js代码.博主是一个喜欢偷懒的人,总觉得这些基础的增删改查效果能不能通过一个什么工具直接生成页面效果,啥代码都不用写了,那该多爽.于是研究了下T4 ...
- JS组件系列——BootstrapTable+KnockoutJS实现增删改查解决方案(三):两个Viewmodel搞定增删改查
前言:之前博主分享过knockoutJS和BootstrapTable的一些基础用法,都是写基础应用,根本谈不上封装,仅仅是避免了html控件的取值和赋值,远远没有将MVVM的精妙展现出来.最近项目打 ...
- 总结一下项目中遇到的分页问题,使用bootstrap-table来做的后台分页,大家可以借鉴一下 (分页第一篇)
前台进入bootstrap的js和css文件,我就不多少了,另外要引进bootstrap-table的js和css 废话不多说,直接代码. 框架为ssm,代码很清楚 <div class=& ...
- JS组件系列——BootstrapTable+KnockoutJS实现增删改查解决方案(二)
前言:上篇 JS组件系列——BootstrapTable+KnockoutJS实现增删改查解决方案(一) 介绍了下knockout.js的一些基础用法,由于篇幅的关系,所以只能分成两篇,望见谅!昨天就 ...
- 级联两个bootstrap-table。一张表显示相关的数据,通过点击这张表的某一行,传过去对应的ID,刷新另外一张表。
二张表的代码(我用的插件,大家可以去网上直接下载http://issues.wenzhixin.net.cn/bootstrap-table/): <div class="contai ...
- bootstrap-table填坑之旅<二>事件
接着研究bootstrap-table... ... 这一篇研究bootstrap-table的事件及回调函数 先上一个demo HTML <div class="alert aler ...
- bootstrap-table填坑之旅<一>认识bootstrap-table
应公司需求,改版公司ERP的数据显示样式.由于前期开发的样式是bootstrap,所以选bootstrap-table理所当然(也是因为看了bootstrap-table官网的example功能强大, ...
随机推荐
- 应如何取B/S的B端的IP
我们常讨论说要取真实IP,不同场景所谓的真实IP含义不一样. 如你要根据客户端IP去判断客户所在区域,那么要记录客户的出口IP,这里的出口IP才是你所谓的真实IP. 如你要判断多个客户端是不是同一个, ...
- 被误解的MVC和被神化的MVVM(转)
转载自:http://www.infoq.com/cn/articles/rethinking-mvc-mvvm 原文作者:唐巧 被误解的 MVC MVC 的历史 MVC,全称是 Model View ...
- 配置本机IIS服务器
1.控制面板---程序---(程序和功能) 安装完成之后就可以访问本地的localhost 2.进入防火墙界面--高级设置 至此开放端口完成
- Nginx相关集合
http://www.cnblogs.com/kamil/p/5163182.html LNMP搭建(yum) Nginx基本使用 http://www.cnblogs.com/kamil/p/516 ...
- mybatis-generator 1.3.5支持流式 fluent 方法
在以往的无数此写model的过程中,大家都会烦恼model的set方法写一堆.比如 Person p = new Person(); p.setName("name"); p.se ...
- django的cookie和session以及内置信号、缓存
cookie和session cookie和session的作用: cookie和session都记录了客户端的某种状态,用来跟踪用户访问网站的整个回话.两者最大的区别是cookie的信息是存放在浏览 ...
- Shell入门
前言 日常用Python多一些,不过很多时候shell脚本更简单实用一些,所以有必要熟悉一下shell脚本.当然shell有他特定的一些场景,比方说我曾经改过一个vpn断线自动重连的脚本,简单实用. ...
- Redis五种数据结构简介
Redis五种结构 1.String 可以是字符串,整数或者浮点数,对整个字符串或者字符串中的一部分执行操作,对整个整数或者浮点执行自增(increment)或者自减(decrement)操作. 字符 ...
- Apriori算法的原理与python 实现。
前言:这是一个老故事, 但每次看总是能从中想到点什么.在一家超市里,有一个有趣的现象:尿布和啤酒赫然摆在一起出售.但是这个奇怪的举措却使尿布和啤酒的销量双双增加了.这不是一个笑话,而是发生在美国沃尔玛 ...
- ThinkPhp 3.2 ajax无刷新分页(未完全改完,临时凑合着用)
临时更改后的page类(很多地方没修改...因为笔者PHP没学好..)如下: <?phpnamespace Fenye\libs; /** file: page.class.php 完美分 ...