Home  >  Article  >  php教程  >  Bootstrap is the perfect way to implement queries

Bootstrap is the perfect way to implement queries

高洛峰
高洛峰Original
2016-12-08 16:36:061223browse

Bootstrap, from Twitter, is currently the most popular front-end framework. Bootstrap is based on HTML, CSS, and JAVASCRIPT. It is simple and flexible, making web development faster.

Without further ado, I’ll just post the bootstrap code to implement the query. The specific code is as follows:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<title><%=request.getParameter("title") %></title> 
</head>
<body>
<!-- 头部引入 -->
<%@ include file="/jsp/public/header.jspf" %>
<div>
<!-- 左侧菜单 -->
<%@ include file="/jsp/public/menu.jsp" %>
<div>
<div>
<div> 
<a href=""><span></span></a> <span></span> <span><%=request.getParameter("title") %></span>
</div>
<!-- 操作部分 -->
<div class="bgroup text-right">
<!-- <s:a action="dataRule_addUI" cssClass="button bPrimary"><i></i>新增</s:a>
<a href="###" class="button bSuccess" onclick="editRule();"><i></i>编辑</a>
<a href="###" class="button bInfo" onclick="collectRule();"><i></i>收藏</a>
<a href="###" class="button bDanger" onclick="delRule();" id="delRuleId"><i></i>删除</a> -->
</div>
<div>
<!-- 表单部分 -->
<form id="taskList_form">
<div>
<c:set var="querywhere" value="state=&#39;1&#39;"/>
<c:if test="${not empty param.pdKey}"><c:set var="querywhere" value="pdKey=&#39;${param.pdKey}&#39;"/></c:if>
流程名称:<OATag:select cssclass="form-control pdKey" name="pdKey" classname="ProcDefExtend" listkey="pdName" otherattr="${not empty param.pdKey?&#39;disabled&#39;:&#39;&#39;}" listvalue="pdKey" querywhere="${querywhere}" value="${param.pdKey}" auth="false"/>
</div>
<div>
开单人:<input name="openUserName" onkeypress="if(event.keyCode==13){$(&#39;#bnt_search&#39;).click();return false;}"/>
</div>
<div class="form-group pdate">
<label for="date">送达时间:</label>
<input class="form-control layer-date" id="start" placeholder="请选择开始日期" name="startDate" />
<i></i>
</div>
<div class="form-group pdate">
<label for="date">至</label>
<input class="form-control layer-date" id="end" placeholder="请选择结束日期" name="endDate"/>
<i></i>
</div>
<%-- <div>
<label for="keywords">关键词:</label>
<s:textfield type="text" cssClass="form-control" name="keyword" id="keywords" value="%{keyword}" placeholder="请输入关键词"/>
</div> --%>
<div> 
<a href="javascript:void(0);" class="button bPrimary" id="bnt_search" onclick="_search();"><i></i>查询</a>
</div>
</form>
<!-- 表格部分 -->
<div>
<div>
<div id="toolbar"><a href="javascript:void(0);" onclick="batchSignTask(&#39;同意&#39;,&#39;ok&#39;);"><i class="icon iconfont"></i>批量同意/提交</a></div>
<table id="taskList_table" class="table-striped table-hover" data-mobile-responsive="true"></table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript">
var $table = $("#taskList_table"); 
$table.bootstrapTable({
url: &#39;${ctx}/task_list.action&#39;, //请求后台的URL(*)
method: &#39;post&#39;, //请求方式(*)
toolbar: &#39;#toolbar&#39;, //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
contentType: "application/x-www-form-urlencoded",
sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
pageNumber: 1,
pageSize: 10,
pageList: [10, 25, 50, 100, &#39;All&#39;],
smartDisplay: false,//智能显示分页按钮
paginationPreText: "上一页",
paginationNextText: "下一页",
queryParams: function (params) {
return {
rows: this.pageSize,
page: this.pageNumber,
webRequest: true,
/* pdKey:"${not empty param.pdKey?param.pdKey:&#39;&#39;}" */
pdKey:$(".pdKey").val(),
openUserName:$("input[name=&#39;openUserName&#39;]").val(),
startDate:$("input[name=&#39;startDate&#39;]").val(),
endDate:$("input[name=&#39;endDate&#39;]").val()
};
},
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: true,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: true, //是否启用点击选中行
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
idField : &#39;DBID_&#39;,
sortName : &#39;CREATE_&#39;,
sortOrder : &#39;desc&#39;,
sortable: true, //是否启用排序
columns:[[
{field:&#39;DBID_&#39;,checkbox:true},
{field:&#39;flowImg&#39;,title:&#39;签核图&#39;,width:100,formatter:function(value,rowData,rowIndex){
return &#39;<img src="/common/js/jquery-easyui-1.3.3/themes/icons/workflow.png" style="Cursor:pointer" title="流程图" alt="流程图" onclick="top.tabShow(\&#39;流程图:&#39;+rowData.pdName+&#39;\&#39;,\&#39;${ctx}/workflow/central!trackTask.action?proDbId=&#39;+rowData.PROCINST_+&#39;\&#39;)"/>&#39;; 
}},
{field:&#39;pdName&#39;,title:&#39;流程名称&#39;,sortable:true,width:180},
{field:&#39;flowNo&#39;,title:&#39;编号&#39;,width:200,formatter:function(value,rowData,rowIndex){
var div = &#39;<a href="#" onclick="top.tabShow(\&#39;&#39;+rowData.pdName+&#39;\&#39;,\&#39;/workflow/central!showTaskForm.action?taskId=&#39;+rowData.DBID_+&#39;\&#39;)">&#39;+value+&#39;</a>&#39;; 
return div;
}}, 
{field:&#39;ACTIVITY_NAME_&#39;,title:&#39;关卡名称&#39;,width:200}, 
{field:&#39;keyWord_&#39;,title:&#39;主旨&#39;,width:400},
{field:&#39;username&#39;,title:&#39;开单人&#39;,width:100},
{field:&#39;prevMemberName_&#39;,title:&#39;送出人&#39;,width:100}, 
{field:&#39;CREATE_&#39;,title:&#39;送达时间&#39;,sortable:true,width:200}, 
{field:&#39;TASKSTATE_&#39;,title:&#39;状态&#39;,width:200,formatter:function(value,rowData,rowIndex){
var div = &#39;未读&#39;; 
if("2"==value){
div="已读";
}
return div;
}}
]]
});
//初次5分钟后执行
window.setTimeout(_search, 1000*60*5);
//-处理搜索功能------------------------------------
//搜索按钮绑定回车事件
document.onkeydown = function(event){
if (event.keyCode == 13) {
event.cancelBubble = true;
event.returnValue = false;
_search();
}
} 
function _search() {
$table.bootstrapTable(&#39;refresh&#39;, {url: &#39;${ctx}/task_list.action&#39;}); 
/* var data = null;
var pdKey = $(".pdKey").val();
var openUserName=$("input[name=&#39;openUserName&#39;]").val();
var startDate=$("input[name=&#39;startDate&#39;]").val();
var endDate=$("input[name=&#39;endDate&#39;]").val();
var pageSize = $(".page-size")[0].firstChild.data;
var pageNumber = $(".page-number.active a").text();
if(pdKey!=null){
data={rows:pageSize,page:pageNumber,pdKey:pdKey,openUserName:openUserName,startDate:startDate,endDate:endDate,webRequest: true};
}else{
data={rows:pageSize,page:pageNumber,webRequest:true,pdKey:"${not empty param.pdKey?param.pdKey:&#39;&#39;}"};
}
$.ajax({
url:&#39;${ctx}/workflow/central!findTaskList.action&#39;,
type:&#39;post&#39;,
dataType:&#39;json&#39;,
data:data, 
success:function(json,textstatus){
$table.bootstrapTable(&#39;removeAll&#39;);
$table.bootstrapTable(&#39;load&#39;,json);
}
}); */
}
/**
*批次操作表单
*/
function batchSignTask(signTypeLabel,signType){
var rows = $table.bootstrapTable(&#39;getSelections&#39;);
if(rows.length>0){
var taskId="";
for(var i=0;i<rows.length;i++){
if(taskId!=""){
taskId +=",";
}
taskId += rows[i].DBID_;
}
top.sy.dialogSimp({title:&#39;签核视窗&#39;,queryParams:{&#39;signTypeLabel&#39;:signTypeLabel,&#39;signType&#39;:signType},href : &#39;${ctx}/jsp/workflow/dialog/signCommentWin.jsp&#39;}
,&#39;${ctx}/workflow/central!signTask.action?batchSignTask=1&taskId=&#39;+taskId
,wf_tl_data);
}else{
Confirm.show(&#39;提示&#39;, &#39;请选取要批次操作的数据行!&#39;);
}
}
</script>
<script type="text/javascript">
// 日历控件处理
var start = {
elem: &#39;#start&#39;,
format: &#39;YYYY-MM-DD&#39;,
/* min: laydate.now(), //设定最小日期为当前日期 */
max: &#39;2099-06-16&#39;, //最大日期
istime: true,
istoday: false,
choose: function(datas){
end.min = datas; //开始日选好后,重置结束日的最小日期
end.start = datas //将结束日的初始值设定为开始日
}
};
var end = {
elem: &#39;#end&#39;,
format: &#39;YYYY-MM-DD&#39;,
/* min: laydate.now(), */
max: &#39;2099-06-16&#39;,
istime: true,
istoday: false,
choose: function(datas){
start.max = datas; //结束日选好后,重置开始日的最大日期
}
};
laydate(start);
laydate(end);
laydate.skin(&#39;molv&#39;); 
</script>
</html>

The above is the perfect method for implementing queries in Bootstrap introduced by the editor. I hope it will be helpful to everyone


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn