428 lines
19 KiB
Plaintext
428 lines
19 KiB
Plaintext
<%@ page language="java" pageEncoding="UTF-8" %>
|
||
<%@page import="com.sipai.entity.work.MPointHisChangeData" %>
|
||
<%request.setAttribute("Change_Delete", MPointHisChangeData.Change_Delete);%>
|
||
<%request.setAttribute("Change_Edit", MPointHisChangeData.Change_Edit);%>
|
||
<%request.setAttribute("Change_Add", MPointHisChangeData.Change_Add);%>
|
||
|
||
<!--bootstrap-edittable 表格行内编辑 -->
|
||
<link rel="stylesheet" href="<%=request.getContextPath()%>/plugins/bootstrap-editable/css/bootstrap-editable.css"/>
|
||
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/bootstrap-editable/js/bootstrap-editable.js" charset="utf-8"></script>
|
||
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/bootstrap-editable/js/bootstrap-table-editable.js" charset="utf-8"></script>
|
||
<style type="text/css">
|
||
.input-group-sm>.form-control,
|
||
.input-group-sm>.input-group-addon,
|
||
.input-group-sm>.input-group-btn>.btn{
|
||
padding: 5px;
|
||
}
|
||
.form-horizontal .form-group {
|
||
margin-bottom: 5px;
|
||
margin-left: 0;
|
||
margin-right: 0;
|
||
}
|
||
.border-right{
|
||
border-right: 1px solid #ccc;
|
||
}
|
||
</style>
|
||
<script type="text/javascript">
|
||
var beginTimeStore = '';
|
||
var endTimeStore = '';
|
||
$(function () {
|
||
//定义locale汉化插件
|
||
beginTimeStore = moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm');
|
||
endTimeStore = moment().format('YYYY-MM-DD HH:mm');
|
||
var locale = {
|
||
"format": 'YYYY-MM-DD HH:mm',
|
||
"separator": " ~ ",
|
||
"applyLabel": "确定",
|
||
"cancelLabel": "取消",
|
||
"fromLabel": "起始时间",
|
||
"toLabel": "结束时间'",
|
||
"customRangeLabel": "自定义",
|
||
"weekLabel": "W",
|
||
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
|
||
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
||
"firstDay": 1
|
||
};
|
||
$('#reservationtime').daterangepicker({
|
||
"timePicker": true,
|
||
"timePicker24Hour": true,
|
||
"linkedCalendars": false,
|
||
"autoUpdateInput": false,
|
||
"timePickerIncrement": 10,
|
||
"locale": locale,
|
||
//汉化按钮部分
|
||
ranges: {
|
||
'今日': [moment().subtract(1, 'days'), moment()],
|
||
'昨日': [moment().subtract(2, 'days'), moment().subtract(1, 'days')],
|
||
'最近7日': [moment().subtract(7, 'days'), moment()],
|
||
'本月': [moment().startOf('month'), moment().endOf('month')],
|
||
'上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||
},
|
||
startDate: beginTimeStore,
|
||
endDate: endTimeStore
|
||
}, function (start, end, label) {
|
||
beginTimeStore = start.format(this.locale.format);
|
||
endTimeStore = end.format(this.locale.format);
|
||
if (!this.startDate) {
|
||
this.element.val('');
|
||
} else {
|
||
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
||
}
|
||
// doHisDataSearch();
|
||
});
|
||
$('#reservationtime').val(beginTimeStore + locale.separator + endTimeStore);
|
||
|
||
inHisDataTable();
|
||
})
|
||
|
||
function inHisDataTable() {
|
||
var hisDataTable = $('#hisDataTable');
|
||
hisDataTable.bootstrapTable({ // 对应table标签的id
|
||
url: ext.contextPath + '/work/mpoint/getHisDataList.do', // 获取表格数据的url
|
||
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||
striped: true, //表格显示条纹,默认为false
|
||
pagination: true, // 在表格底部显示分页组件,默认false
|
||
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
|
||
pageSize: 10, // 页面数据条数
|
||
pageNumber: 1, // 首页页码
|
||
sidePagination: 'server', // 设置为服务器端分页
|
||
uniqueId:"itemid",
|
||
queryParams: function (params) { // 请求服务器数据时发送的参数,可以在这里添加额外的查询参数,返回false则终止请求
|
||
return {
|
||
rows: params.limit, // 每页要显示的数据条数
|
||
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
|
||
sort: params.sort, // 要排序的字段
|
||
order: params.order,
|
||
mpid: '${param.mpcode}',
|
||
sdt: beginTimeStore,
|
||
edt: endTimeStore,
|
||
bizid: '${param.unitId}',
|
||
maxData: $('#maxData').val(),
|
||
minData: $('#minData').val(),
|
||
equalData: $('#equalData').val(),
|
||
}
|
||
},
|
||
sortName: 'measuredt', // 要排序的字段
|
||
sortOrder: 'desc', // 排序规则
|
||
columns: [
|
||
{
|
||
field: 'measuredt', // 返回json数据中的name
|
||
title: '时间', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
width: '210px',
|
||
formatter: function (value, row, index) {
|
||
if(value.length>22){
|
||
return value;
|
||
}else{
|
||
return value.substring(0, 16);
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'parmvalue', // 返回json数据中的name
|
||
title: '当前值', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
editable: { //编辑列元素
|
||
type: 'text',
|
||
title: '值',
|
||
mode: "inline",
|
||
validate: function (v) {
|
||
if (!v) return '值不能为空';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'oldData', // 返回json数据中的name
|
||
title: '原始值', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
formatter: function (value, row, index) {
|
||
return value
|
||
}
|
||
},
|
||
{
|
||
field: 'memo',
|
||
title: "操作",
|
||
align: 'center',
|
||
valign: 'middle',
|
||
width: 50, // 定义列的宽度,单位为像素px
|
||
formatter: function (value, row, index) {
|
||
if(value!=null && value!=undefined){
|
||
if(value.length>22){
|
||
return value;
|
||
}else{
|
||
return '<div class="btn-group">'+
|
||
'<button class="btn btn-default btn-sm" onclick="delMPointHistory(\''+row.itemid+'\',\''+row.measuredt+'\',\''+row.parmvalue+'\')" title="删除"><i class="fa fa-trash-o"></i></button>'+
|
||
'</div>';
|
||
}
|
||
}else{
|
||
return '';
|
||
}
|
||
}
|
||
}
|
||
],
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
adjustBootstrapTableView("hisDataTable");
|
||
getHisData4Screen();
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.info("加载数据失败");
|
||
},
|
||
//保存列修改后的数据
|
||
onEditableSave: function (field, row, oldValue, $el) {
|
||
if(row.itemid!=null && row.itemid!=undefined && row.itemid!='newData'){
|
||
if(row.parmvalue != oldValue){
|
||
upHisDateValue(row.measuredt, row.parmvalue, oldValue);
|
||
}else{
|
||
showAlert('d','修改数据与原始数据相同','mPointHisChangeDataAlertdiv');
|
||
}
|
||
}else{
|
||
var measuredt = $("#hisDataModal #measuredt").val();
|
||
if(measuredt!=null && measuredt!=undefined && measuredt!=''){
|
||
saveMPointHistory(measuredt, row.parmvalue);
|
||
}else{
|
||
showAlert('d','请选择时间','mPointHisChangeDataAlertdiv');
|
||
hisDataTable.bootstrapTable('removeByUniqueId',row.itemid);
|
||
insertTableRow(row.parmvalue);
|
||
}
|
||
}
|
||
},
|
||
});
|
||
|
||
}
|
||
//获取最大值、最小值、平均值等
|
||
function getHisData4Screen() {
|
||
$.post(ext.contextPath + "/work/mpoint/getHisData4Screen.do", {
|
||
mpid: '${param.mpcode}',
|
||
sdt: beginTimeStore,
|
||
edt: endTimeStore,
|
||
bizid: '${param.unitId}',
|
||
maxData: $('#maxData').val(),
|
||
minData: $('#minData').val(),
|
||
equalData: $('#equalData').val(),
|
||
},function(result) {
|
||
var data= $.parseJSON(result);
|
||
var hisData4ScreenStr = "";
|
||
if(data.avg!=null && data.avg!=undefined && data.avg!=''){
|
||
hisData4ScreenStr+='<li>平均值:'+data.avg+';</li>';
|
||
}
|
||
if(data.max!=null && data.max!=undefined && data.max!=''){
|
||
hisData4ScreenStr+='<li>最大值:'+data.max+';</li>';
|
||
}
|
||
if(data.min!=null && data.min!=undefined && data.min!=''){
|
||
hisData4ScreenStr+='<li>最小值:'+data.min+';</li>';
|
||
}
|
||
$("#hisData4Screen").html(hisData4ScreenStr);
|
||
});
|
||
}
|
||
function insertTableRow(parmvalue) {
|
||
if($("#hisDataModal #measuredt").length > 0){
|
||
showAlert('d','已存在!','mPointHisChangeDataAlertdiv');
|
||
}else{
|
||
if(parmvalue==null || parmvalue==undefined || parmvalue==''){
|
||
parmvalue = 0;
|
||
}
|
||
var newData = [{
|
||
itemid:'newData',
|
||
measuredt: '<input type="text" class="form-control" id="measuredt" placeholder="请先点击选择时间" readonly/>',
|
||
parmvalue: parmvalue,
|
||
}];
|
||
$('#hisDataTable').bootstrapTable('prepend', newData);
|
||
$("#measuredt").datetimepicker({
|
||
todayBtn: true,
|
||
clearBtn: true,
|
||
autoclose: true,
|
||
todayHighlight: 1,//今天高亮
|
||
endDate: new Date(),
|
||
minuteStep: 5, //分钟间隔为5分
|
||
format: 'yyyy-mm-dd hh:ii',
|
||
startView: "month", //初始化视图
|
||
minView: 0,
|
||
maxView: "year",
|
||
language: 'zh-CN'
|
||
}).on('changeDate', function (ev) {
|
||
|
||
});
|
||
}
|
||
}
|
||
function doHisDataSearch() {
|
||
$("#hisDataTable").bootstrapTable('refresh');
|
||
}
|
||
|
||
function delMPointHistory(itemid,measuredt,parmValue) {
|
||
$.post(ext.contextPath + "/work/mpoint/delMPointHistory.do", {
|
||
unitId: '${param.unitId}',
|
||
mpid: '${param.mpcode}',
|
||
itemid: itemid,
|
||
},function(result) {
|
||
var data= $.parseJSON(result);
|
||
if (data.code == 1) {
|
||
$.post(ext.contextPath + "/work/mPointHisChangeData/dosave.do", {
|
||
measuredt: measuredt,
|
||
mpid: '${param.mpcode}',
|
||
olddata: parmValue,
|
||
changeType: '${Change_Delete}'
|
||
});
|
||
doHisDataSearch();
|
||
}else{
|
||
showAlert('d','删除失败!','mPointHisChangeDataAlertdiv');
|
||
}
|
||
});
|
||
}
|
||
|
||
function saveMPointHistory(measuredt, parmValue) {
|
||
$.post(ext.contextPath + "/work/mpoint/saveMPointHistory.do", {
|
||
measuredt: measuredt,
|
||
parmValue: parmValue,
|
||
unitId: '${param.unitId}',
|
||
mpid: '${param.mpcode}'
|
||
},function(result) {
|
||
var data= $.parseJSON(result);
|
||
if (data.code == 1) {
|
||
$.post(ext.contextPath + "/work/mPointHisChangeData/dosave.do", {
|
||
measuredt: measuredt,
|
||
mpid: '${param.mpcode}',
|
||
newValue: parmValue,
|
||
changeType: '${Change_Add}'
|
||
});
|
||
doHisDataSearch();
|
||
}else{
|
||
showAlert('d','添加失败!','mPointHisChangeDataAlertdiv');
|
||
}
|
||
});
|
||
}
|
||
|
||
function upHisDateValue(measuredt, newValue, olddata) {
|
||
$.post(ext.contextPath + "/work/mpoint/upHisDateValue.do", {
|
||
measuredt: measuredt,
|
||
unitId: '${param.unitId}',
|
||
mpid: '${param.mpcode}',
|
||
newValue: newValue
|
||
},function(result) {
|
||
var data= $.parseJSON(result);
|
||
if (data.code == 1) {
|
||
$.post(ext.contextPath + "/work/mPointHisChangeData/dosave.do", {
|
||
measuredt: measuredt,
|
||
mpid: '${param.mpcode}',
|
||
newValue: newValue,
|
||
olddata: olddata,
|
||
changeType: '${Change_Edit}'
|
||
});
|
||
doHisDataSearch();
|
||
}else{
|
||
showAlert('d','修改失败!','mPointHisChangeDataAlertdiv');
|
||
}
|
||
});
|
||
}
|
||
|
||
function showChange() {
|
||
$.post(ext.contextPath + '/work/mPointHisChangeData/doView.do', {mpcode: '${param.mpcode}'}, function (data) {
|
||
$("#hisChangeDataDiv").html(data);
|
||
openModal('hisChangeDataModal');
|
||
});
|
||
}
|
||
function exportExcel() {
|
||
showAlert('s','导出中...','mPointHisChangeDataAlertdiv');
|
||
var iframe = document.getElementById("theone")
|
||
iframe.src=ext.contextPath + "/work/mpoint/HisDataExportExcel.do?mpid=${param.mpcode}&sdt="+beginTimeStore
|
||
+"&edt="+endTimeStore+"&bizid=${param.unitId}&maxData="+$('#maxData').val()+"&minData="+$('#minData').val()+"&equalData="+$('#equalData').val();
|
||
}
|
||
|
||
|
||
function importExcelMPoint(){
|
||
$.post(ext.contextPath + "/work/mpoint/getUnType.do?unitId=" + unitId, {} , function(res) {
|
||
var resp = eval('(' + res + ')');
|
||
if (resp.status) {
|
||
$.post(ext.contextPath + '/work/mpoint/importMpointHis.do?mpid=${param.mpcode}&bizid=${param.unitId}', {} , function(data) {
|
||
$("#subHisDiv").html(data);
|
||
openModal('subModal');
|
||
});
|
||
} else {
|
||
showAlert('d',resp.msg,'mainAlertdiv');
|
||
}
|
||
});
|
||
}
|
||
|
||
</script>
|
||
<div class="modal fade" id="hisDataModal">
|
||
<div class="modal-dialog modal-xlg">
|
||
<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">
|
||
<div id="mPointHisChangeDataAlertdiv"></div>
|
||
<!-- 新增界面formid强制为subForm -->
|
||
<form class="form-horizontal" id="subForm">
|
||
<div class="form-group bg-info">
|
||
<div class="row">
|
||
<label class="col-sm-1 control-label">ID</label>
|
||
<div class="col-sm-3 border-right">
|
||
<p class="form-control-static" >${mPoint.id}</p>
|
||
</div>
|
||
<label class="col-sm-1 control-label">名称</label>
|
||
<div class="col-sm-5 border-right">
|
||
<p class="form-control-static" >${mPoint.parmname}</p>
|
||
</div>
|
||
<label class="col-sm-1 control-label">单位</label>
|
||
<div class="col-sm-1">
|
||
<p class="form-control-static" >${mPoint.unit}</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="row" style="margin-bottom: 5px;">
|
||
<div class="col-lg-9">
|
||
<div class="input-group input-group-sm">
|
||
<span class="input-group-addon">单值</span>
|
||
<input type="number" class="form-control" id="equalData" placeholder="单值">
|
||
<span class="input-group-addon">值范围</span>
|
||
<input type="number" class="form-control" id="minData" placeholder="下限">
|
||
<span class="input-group-addon">-</span>
|
||
<input type="number" class="form-control" id="maxData" placeholder="上限">
|
||
<span class="input-group-addon">时间</span>
|
||
<input type="text" class="form-control" id="reservationtime" style="width:225px;">
|
||
<span class="input-group-btn">
|
||
<button type="button" class="btn btn-default" onclick="doHisDataSearch();"><i
|
||
class="fa fa-search"></i> 查询
|
||
</button>
|
||
</span>
|
||
</div><!-- /input-group -->
|
||
</div>
|
||
<div class="col-lg-3 text-right">
|
||
<div class="btn-group btn-group-sm" role="group" aria-label="..." style="width: 300px">
|
||
<button type="button" class="btn btn-default" onclick="insertTableRow();" style="margin-left: 5px;">
|
||
<i class="fa fa-plus"></i> 添加</button>
|
||
<button type="button" class="btn btn-default" onclick="showChange();" style="margin-left: 5px;">
|
||
<i class="fa fa-book"></i> 记录</button>
|
||
<button type="button" class="btn btn-default" onclick="exportExcel();" style="margin-left: 5px;">
|
||
<i class="fa fa-file-excel-o"></i> 导出</button>
|
||
<button type="button" class="btn btn-default" onclick="importExcelMPoint();" style="margin-left: 5px;">
|
||
<i class="fa fa-file-excel-o"></i> 导入</button>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.row -->
|
||
<div class="input-group-btn pull-right">
|
||
</div>
|
||
</form>
|
||
<div id="container">
|
||
<table id="hisDataTable"></table>
|
||
</div>
|
||
<div style="display:none;">
|
||
<iframe id="theone" src=""></iframe>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<ul class="list-inline pull-left" id="hisData4Screen"></ul>
|
||
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">关闭</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div>
|