first commit
This commit is contained in:
332
WebRoot/jsp/maintenance/libraryMaintainCarDetail4Select.jsp
Normal file
332
WebRoot/jsp/maintenance/libraryMaintainCarDetail4Select.jsp
Normal file
@ -0,0 +1,332 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<script type="text/javascript">
|
||||
var doSearchEqu = function() {
|
||||
$("#table_equ1").bootstrapTable('refresh');
|
||||
};
|
||||
function doSelectEqu(dialog,grid) {
|
||||
//var checkedItems = $("#table_user").bootstrapTable('getAllSelections');
|
||||
|
||||
var checkedItems = $("#table_equ1").bootstrapTable('getSelections');
|
||||
var datas = "";
|
||||
$.each(checkedItems, function (index, item) {
|
||||
datas += item.id;
|
||||
});
|
||||
|
||||
datas_name="";
|
||||
datas_money="";
|
||||
datas_workingHours="";
|
||||
|
||||
console.info(datas)
|
||||
if(datas!=""){
|
||||
$.post(ext.contextPath + '/maintenance/libraryMaintainCar/getDetaillist.do', {id:'${param.maintainCarId}',checkedIds : datas,page:1,rows:50}, function(resp) {
|
||||
$.each(resp.rows, function(index, item){
|
||||
if(datas_name!=""){
|
||||
datas_name+=",";
|
||||
datas_money+=",";
|
||||
datas_workingHours+=",";
|
||||
}
|
||||
datas_name+=item.num10thousandKm;
|
||||
datas_money+=item.money;
|
||||
datas_workingHours+=item.workingHours;
|
||||
});
|
||||
$('#${param.formId} #${param.hiddenId}' ).val(datas);
|
||||
$('#${param.formId} #${param.textId}').val(datas_name);
|
||||
$('#${param.formId} #${param.moneyId}').val(datas_money);
|
||||
$('#${param.formId} #${param.workingHoursId}').val(datas_workingHours);
|
||||
closeModal("equipmentDetail4SelectModal")
|
||||
},'json');
|
||||
}else{
|
||||
$('#${param.formId} #${param.hiddenId}' ).val(datas);
|
||||
$('#${param.formId} #${param.textId}').val(datas_name);
|
||||
$('#${param.formId} #${param.moneyId}').val(datas_money);
|
||||
$('#${param.formId} #${param.workingHoursId}').val(datas_workingHours);
|
||||
closeModal("equipmentDetail4SelectModal")
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
function stateFormatter(value, row, index) {
|
||||
var flag=false;
|
||||
$.each(eval('${maintainCarDetails}'), function(index, item){
|
||||
if(row.id==item.id){
|
||||
flag=true;
|
||||
}
|
||||
});
|
||||
if (flag)
|
||||
return {
|
||||
checked : true//设置选中
|
||||
};
|
||||
return value;
|
||||
}
|
||||
|
||||
var $table1;
|
||||
var switchStatus=false;
|
||||
var selectionIds = []; //保存选中ids
|
||||
|
||||
function initialSelectionIds(){
|
||||
var check_array =eval('${maintainCarDetails}');
|
||||
if(check_array!=null&& check_array.length>0){
|
||||
selectionIds =new Array(check_array.length);
|
||||
for(var i=0;i<check_array.length;i++){
|
||||
selectionIds[i]=check_array[i].id;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getCheckedIds(){
|
||||
var ids="";
|
||||
var check_array =eval('${maintainCarDetails}');
|
||||
$.each(check_array, function(index, item){
|
||||
if(ids!=""){
|
||||
ids+=",";
|
||||
}
|
||||
ids+=item.id;
|
||||
});
|
||||
return ids;
|
||||
}
|
||||
function queryParams(params) {
|
||||
|
||||
var temp={
|
||||
rows: params.limit, // 每页要显示的数据条数
|
||||
page: params.offset/params.limit+1, // 每页显示数据的开始页码
|
||||
sort: params.sort, // 要排序的字段
|
||||
order: params.order,
|
||||
// search_name : $('#search_equName').val(),
|
||||
id: '${param.maintainCarId}',
|
||||
};
|
||||
var status =$('#switchBtn').bootstrapSwitch('state')
|
||||
if(status){
|
||||
temp.checkedIds=getCheckedIds();
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
// var companyId= '${param.companyId}';
|
||||
$(function() {
|
||||
$("#searchEquForm").attr("onsubmit","return false;");
|
||||
$("#searchEquForm").keyup(function(){
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
//回车查询
|
||||
doSearchEqu();
|
||||
event.stopPropagation();
|
||||
}
|
||||
})
|
||||
|
||||
// $.post(ext.contextPath + "/user/processSection/getProcessSection4Select.do", {companyId:companyId}, function(data) {
|
||||
// var selelct_ =$("#processSection").select2({
|
||||
// data: data,
|
||||
// cache : false,
|
||||
// placeholder:'请选择',//默认文字提示
|
||||
// allowClear: true,//允许清空
|
||||
// escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||||
// language: "zh-CN",
|
||||
// minimumInputLength: 0,
|
||||
// minimumResultsForSearch: 10,//数据超过十个启用搜索框
|
||||
// formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果
|
||||
// formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择
|
||||
// });
|
||||
// $(".select2-selection--single").css({'height':'30px','paddingTop':'4px'});
|
||||
// selelct_.val("").trigger("change");
|
||||
// /* selelct_.on("change",function(e){
|
||||
// dosearch();
|
||||
// }); */
|
||||
// },'json');
|
||||
|
||||
|
||||
//jquery html()方法加载,导致box无法执行boxwidget(),手动初始化
|
||||
$('#searchBox').boxWidget();
|
||||
$('#switchBtn').bootstrapSwitch({
|
||||
onText:'是',
|
||||
offText:'否',
|
||||
size:"small",
|
||||
})
|
||||
$(".select2-selection--single").css({'height':'30px','paddingTop':'4px'});
|
||||
|
||||
initialSelectionIds();
|
||||
$table1=$("#table_equ1").bootstrapTable({ // 对应table标签的id
|
||||
url: ext.contextPath + '/maintenance/libraryMaintainCar/getDetaillist.do', // 获取表格数据的url
|
||||
//cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||||
clickToSelect:true,
|
||||
singleSelect:true,
|
||||
striped: true, //表格显示条纹,默认为false
|
||||
pagination: true, // 在表格底部显示分页组件,默认false
|
||||
pageList: [10, 20], // 设置页面可以显示的数据条数
|
||||
pageSize: 20, // 页面数据条数
|
||||
pageNumber: 1, // 首页页码
|
||||
sidePagination: 'server', // 设置为服务器端分页
|
||||
responseHandler:responseHandler, //在渲染页面数据之前执行的方法,此配置很重要!!!!!!!
|
||||
queryParams: queryParams,
|
||||
queryParamsType: "limit",
|
||||
sortName: 'num_10thousand_km', // 要排序的字段
|
||||
sortOrder: 'asc', // 排序规则
|
||||
/* showColumns: true,
|
||||
showRefresh: true, */
|
||||
columns: [
|
||||
{
|
||||
checkbox: true, // 显示一个勾选框
|
||||
radio:true,
|
||||
//formatter: stateFormatter
|
||||
formatter: function (i,row) { // 每次加载 checkbox 时判断当前 row 的 id 是否已经存在全局 Set() 里
|
||||
if($.inArray(row.id,Array.from(selectionIds))!=-1){ // 因为 Set是集合,需要先转换成数组
|
||||
return {
|
||||
checked : true // 存在则选中
|
||||
}
|
||||
}
|
||||
}
|
||||
},{
|
||||
field: 'num10thousandKm', // 返回json数据中的name
|
||||
title: '里程(万公里)', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle', // 上下居中
|
||||
width: '30%'
|
||||
}, {
|
||||
field: 'money', // 返回json数据中的name
|
||||
title: '维保费用(元)', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle', // 上下居中
|
||||
width: '40%'
|
||||
}, {
|
||||
field: 'workingHours', // 返回json数据中的name
|
||||
title: '维保工时(小时)', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle', // 上下居中
|
||||
width: '30%'
|
||||
}
|
||||
/*{
|
||||
field: 'processSection.name', // 返回json数据中的name
|
||||
title: '工艺段', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle',
|
||||
width: '20%'
|
||||
},*/
|
||||
/*{
|
||||
field: 'equipmentClass.name', // 返回json数据中的name
|
||||
title: '设备类型', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle',
|
||||
width: '20%'
|
||||
},*/
|
||||
/*{
|
||||
field: 'equipmentstatus', // 返回json数据中的name
|
||||
title: '状态', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle',
|
||||
width: '10%',
|
||||
formatter: function (value, row, index) {
|
||||
switch (value){
|
||||
case '0' :
|
||||
return "禁用";
|
||||
case '1' :
|
||||
return "启用";
|
||||
default :
|
||||
return "";
|
||||
}
|
||||
}
|
||||
},*/
|
||||
],
|
||||
onLoadSuccess: function(){ //加载成功时执行
|
||||
adjustBootstrapTableView("table_equ1");
|
||||
},
|
||||
onLoadError: function(){ //加载失败时执行
|
||||
console.info("加载数据失败");
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
//绑定选中事件、取消事件、全部选中、全部取消
|
||||
$table1.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e, rows) {
|
||||
var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
|
||||
return row.id;
|
||||
});
|
||||
func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference';
|
||||
selectionIds = _[func](selectionIds, ids);
|
||||
});
|
||||
});
|
||||
//选中事件操作数组
|
||||
var union = function(array,ids){
|
||||
$.each(ids, function (i, id) {
|
||||
if($.inArray(id,array)==-1){
|
||||
array[array.length] = id;
|
||||
}
|
||||
});
|
||||
return array;
|
||||
};
|
||||
//取消选中事件操作数组
|
||||
var difference = function(array,ids){
|
||||
$.each(ids, function (i, id) {
|
||||
var index = $.inArray(id,array);
|
||||
if(index!=-1){
|
||||
array.splice(index, 1);
|
||||
}
|
||||
});
|
||||
return array;
|
||||
};
|
||||
var _ = {"union":union,"difference":difference};
|
||||
|
||||
//表格分页之前处理多选框数据
|
||||
function responseHandler(res) {
|
||||
$.each(res.rows, function (i, row) {
|
||||
row.checkStatus = $.inArray(row.id, selectionIds) != -1; //判断当前行的数据id是否存在与选中的数组,存在则将多选框状态变为true
|
||||
});
|
||||
return res;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="modal fade" id="equipmentDetail4SelectModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">选择维保里程定额</h4>
|
||||
</div>
|
||||
<div class="modal-body " style="width:100%">
|
||||
<div id="alertDiv"></div>
|
||||
<div class="box box-primary box-solid collapsed-box" id="searchBox" collapsed>
|
||||
<div class="box-header">
|
||||
<div class="pull-right box-tools">
|
||||
<button type="button" class="btn btn-primary btn-sm pull-right" data-widget="collapse"
|
||||
style="margin-right: 5px;">
|
||||
<i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
<i class="fa fa-search"></i>
|
||||
</div>
|
||||
<div class="box-body collapse" >
|
||||
<form class="form-horizontal " style="padding:0;" id="searchEquForm">
|
||||
<div class="form-group" style="margin-right: 20px;">
|
||||
<label class="control-label col-sm-2 ">名称</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" id="search_equName" name="search_equName" class="form-control input-sm" placeholder="名称" style="width:170px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" style="margin-right: 20px;">
|
||||
|
||||
<label class="col-sm-2 control-label">只看选中</label>
|
||||
<div class="col-sm-4">
|
||||
<div class="switch" data-on="primary" data-off="info">
|
||||
<input id ="switchBtn" type="checkbox" />
|
||||
</div>
|
||||
</div>
|
||||
<div class=" col-sm-6 button-group" style="padding: 0;">
|
||||
<button type ="button" class="btn btn-default btn-sm pull-right" onclick="doSearchEqu();"><i class="fa fa-search"> 搜索</i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="table_equ1" style="height:230px;overflow:auto;width:100%"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||
<button type="button" class="btn btn-primary" onclick="doSelectEqu()">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
Reference in New Issue
Block a user