286 lines
12 KiB
Plaintext
286 lines
12 KiB
Plaintext
<%@ page language="java" pageEncoding="UTF-8" %>
|
||
<%@ page import="com.sipai.tools.SessionManager" %>
|
||
<%
|
||
SessionManager sessionManager = new SessionManager();
|
||
%>
|
||
<%@page import="com.sipai.entity.timeefficiency.TimeEfficiencyCommStr" %>
|
||
<%request.setAttribute("PatrolType_Product", TimeEfficiencyCommStr.PatrolType_Product);%>
|
||
<%request.setAttribute("PatrolType_Equipment", TimeEfficiencyCommStr.PatrolType_Equipment);%>
|
||
|
||
<style type="text/css">
|
||
.select2-container .select2-selection--single {
|
||
height: 34px;
|
||
line-height: 34px;
|
||
}
|
||
|
||
.select2-selection__arrow {
|
||
margin-top: 3px;
|
||
}
|
||
</style>
|
||
|
||
<script type="text/javascript">
|
||
var record = '${param.record}';
|
||
|
||
var dosearchPatrolRecord = function () {
|
||
$("#table_patrolRecord").bootstrapTable('refresh');
|
||
};
|
||
|
||
function doselect() {
|
||
//fucname为传的方法名
|
||
var fucname = '${param.fucname}';
|
||
var datas = "";
|
||
if (recordIds != null && recordIds != '') {
|
||
datas = "[{\"id\":\"" + recordIds.id + "\",\"name\":\"" + recordIds.name + "\"}]";
|
||
}
|
||
// $.each(recordIds, function (index, item) {
|
||
// console.log(item)
|
||
// if (datas != "") {
|
||
// datas += ",";
|
||
// }
|
||
// datas += item;
|
||
// });
|
||
if (datas == "") {
|
||
showAlert('d', '请先选择测量点', 'patrolRecordAlertdiv');
|
||
} else {
|
||
//调用保存点位方法
|
||
eval(fucname + "('" + datas + "')")
|
||
closeModal('subModalPatrolRecord');
|
||
}
|
||
};
|
||
|
||
//显示已经勾选的数据
|
||
/*function stateFormatter(value, row, index) {
|
||
var flag = false;
|
||
if (row.id == '${record}') {
|
||
flag = true;
|
||
checkedItem = "";
|
||
}
|
||
if (flag)
|
||
return {
|
||
checked: true//设置选中
|
||
};
|
||
return value;
|
||
}*/
|
||
|
||
var $table;
|
||
|
||
var recordIds = []; //保存选中ids
|
||
function initialSelectionIds() {
|
||
var check_array = record.split(",");
|
||
if (check_array != null && check_array.length > 0) {
|
||
recordIds = new Array(check_array.length);
|
||
for (var i = 0; i < check_array.length; i++) {
|
||
recordIds[i] = check_array[i];
|
||
}
|
||
}
|
||
}
|
||
|
||
var patrolRecordTime = '';
|
||
$(function () {
|
||
//定义locale汉化插件
|
||
patrolRecordTime = moment().format('YYYY-MM-DD');
|
||
var locale = {
|
||
"format": 'YYYY-MM-DD',
|
||
"separator": " ~ ",
|
||
"applyLabel": "确定",
|
||
"cancelLabel": "取消",
|
||
"fromLabel": "起始时间",
|
||
"toLabel": "结束时间'",
|
||
"customRangeLabel": "自定义",
|
||
"weekLabel": "W",
|
||
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
|
||
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
||
"firstDay": 1
|
||
};
|
||
$('#patrolRecordInputTime').daterangepicker({
|
||
"timePicker": false,
|
||
"timePicker24Hour": true,
|
||
// "timePickerIncrement": 10,
|
||
"singleDatePicker": true,
|
||
"locale": locale,
|
||
startDate: patrolRecordTime,
|
||
}, function (start, end, label) {
|
||
patrolRecordTime = start.format(this.locale.format);
|
||
if (!this.startDate) {
|
||
this.element.val('');
|
||
} else {
|
||
this.element.val(this.startDate.format(this.locale.format));
|
||
}
|
||
dosearchPatrolRecord();
|
||
});
|
||
$('#patrolRecordInputTime').val(patrolRecordTime);
|
||
|
||
initialSelectionIds();
|
||
$('#table_patrolRecord').bootstrapTable('destroy');
|
||
$table = $("#table_patrolRecord").bootstrapTable({ // 对应table标签的id
|
||
url: ext.contextPath + '/timeEfficiency/patrolRecord/getList.do', // 获取表格数据的url
|
||
//cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||
clickToSelect: true,
|
||
striped: true, //表格显示条纹,默认为false
|
||
pagination: true, // 在表格底部显示分页组件,默认false
|
||
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
|
||
pageSize: 10, // 页面数据条数
|
||
pageNumber: 1, // 首页页码
|
||
sidePagination: 'server', // 设置为服务器端分页
|
||
responseHandler: responseHandler, //在渲染页面数据之前执行的方法,此配置很重要!!!!!!!
|
||
queryParams: function (params) { // 请求服务器数据时发送的参数,可以在这里添加额外的查询参数,返回false则终止请求
|
||
return {
|
||
pid: params.pid,
|
||
rows: params.limit, // 每页要显示的数据条数
|
||
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
|
||
sort: params.sort, // 要排序的字段
|
||
order: params.order, // 排序规则
|
||
type: '${PatrolType_Product}',
|
||
sdt: patrolRecordTime + " 00:00",
|
||
edt: patrolRecordTime + " 23:59",
|
||
unitId: unitId
|
||
}
|
||
},
|
||
// queryParamsType: "limit",
|
||
sortName: "startTime", // 要排序的字段
|
||
sortOrder: 'asc', // 排序规则
|
||
columns: [
|
||
{
|
||
checkbox: true,
|
||
formatter: function (i, row) { // 每次加载 checkbox 时判断当前 row 的 id 是否已经存在全局 Set() 里
|
||
if ($.inArray(row.id, Array.from(recordIds)) != -1) { // 因为 Set是集合,需要先转换成数组
|
||
return {
|
||
checked: true // 存在则选中
|
||
}
|
||
}
|
||
},
|
||
width: '40'
|
||
},
|
||
{
|
||
field: 'name', // 返回json数据中的name
|
||
title: '巡检名称', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
formatter: function (value, row, index) {
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.name + "'>" + row.name + "</span>";
|
||
}
|
||
}, {
|
||
field: 'startTime', // 返回json数据中的name
|
||
title: '计划开始时间', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
formatter: function (value, row, index) {
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + value.substring(0, 16) + "'>" + value.substring(0, 16) + "</span>";
|
||
}
|
||
}, {
|
||
field: 'endTime', // 返回json数据中的name
|
||
title: '计划结束时间', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
formatter: function (value, row, index) {
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + value.substring(0, 16) + "'>" + value.substring(0, 16) + "</span>";
|
||
}
|
||
}, {
|
||
field: 'patrolModel', // 返回json数据中的name
|
||
title: '巡检模式', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
formatter: function (value, row, index) {
|
||
if (row.patrolModel == null) {
|
||
return "临时任务";
|
||
} else {
|
||
return row.patrolModel.name;
|
||
}
|
||
}
|
||
}
|
||
],
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
adjustBootstrapTableView("table_patrolRecord");
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.info("加载数据失败");
|
||
}
|
||
|
||
})
|
||
|
||
$table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e, rows, obj) {
|
||
if ('check' == e.type) {
|
||
$('#table_patrolRecord .checked').removeClass("checked");
|
||
obj.parent().addClass("checked");
|
||
recordIds = rows;
|
||
} else {
|
||
obj.parent().removeClass("checked");
|
||
recordIds = "";
|
||
}
|
||
});
|
||
//绑定选中事件、取消事件、全部选中、全部取消
|
||
// $table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e, rows, obj) {
|
||
// var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
|
||
// return row.id;
|
||
// });
|
||
// func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference';
|
||
// recordIds = _[func](recordIds, ids);
|
||
// if ('check' == e.type) {
|
||
// obj.parent().addClass("checked");
|
||
// } else {
|
||
// obj.parent().removeClass("checked");
|
||
// }
|
||
// //adjustBootstrapTableView("table_user");
|
||
// });
|
||
});
|
||
//选中事件操作数组
|
||
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, recordIds) != -1; //判断当前行的数据id是否存在与选中的数组,存在则将多选框状态变为true
|
||
});
|
||
return res;
|
||
}
|
||
|
||
</script>
|
||
<div class="modal fade" id="subModalPatrolRecord">
|
||
<div class="modal-dialog modal-lg" style="width: 1200px">
|
||
<div class="modal-content">
|
||
<div class="modal-body">
|
||
<div id="patrolRecordAlertdiv"></div>
|
||
|
||
<div class="box box-primary">
|
||
<div class="box-header with-border">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span></button>
|
||
<h3 class="box-title">运行巡检记录</h3>
|
||
</div>
|
||
|
||
<div class="form-group pull-right form-inline">
|
||
<input type="text" class="form-control" id="patrolRecordInputTime" name="patrolRecordInputTime"
|
||
style="width: 120px;">
|
||
</div>
|
||
|
||
<div class="table-scrollable">
|
||
<table id="table_patrolRecord" style="table-layout:fixed;"></table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" onclick="doselect()" id="btn_save">确定</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div> |