354 lines
15 KiB
Plaintext
354 lines
15 KiB
Plaintext
|
|
<%@page import="com.sipai.tools.CommString"%>
|
|||
|
|
<%@ page language="java" pageEncoding="UTF-8"%>
|
|||
|
|
<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 masterId='${efficiencyOverviewConfigure.id}';
|
|||
|
|
var tbName='tb_efficiency_overviewConfigure_file'; //数据表
|
|||
|
|
var nameSpace='efficiencyOverviewConfigure';//保存文件夹
|
|||
|
|
var previews = new Array();
|
|||
|
|
var previewConfigs = new Array();
|
|||
|
|
var canvas;
|
|||
|
|
var context;
|
|||
|
|
var height;
|
|||
|
|
var width;
|
|||
|
|
var beauty;
|
|||
|
|
var dataAll;
|
|||
|
|
function showFileInput(ctrlName) {
|
|||
|
|
var control = $('#' + ctrlName);
|
|||
|
|
control.fileinput('destroy');
|
|||
|
|
control.fileinput({
|
|||
|
|
language: 'zh', //设置语言
|
|||
|
|
showUpload: false, //是否显示上传按钮
|
|||
|
|
showRemove:false,
|
|||
|
|
showCaption: false,//是否显示标题
|
|||
|
|
showBrowse:false,//选择按钮
|
|||
|
|
showClose:false,//右上角关闭按钮
|
|||
|
|
dropZoneEnabled: false,//是否显示拖拽区域
|
|||
|
|
fileActionSettings:{
|
|||
|
|
showDrag:false
|
|||
|
|
},
|
|||
|
|
browseClass: "btn btn-primary", //按钮样式
|
|||
|
|
maxFileCount: 10, //表示允许同时上传的最大文件个数
|
|||
|
|
enctype: 'multipart/form-data',
|
|||
|
|
validateInitialCount:true,
|
|||
|
|
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
|
|||
|
|
initialPreviewAsData: true,
|
|||
|
|
initialPreview: previews,
|
|||
|
|
initialPreviewConfig:previewConfigs,
|
|||
|
|
layoutTemplates:{
|
|||
|
|
actionUpload:''
|
|||
|
|
},
|
|||
|
|
deleteUrl:ext.contextPath+"/base/deleteInputFile.do",
|
|||
|
|
deleteExtraData:function () { //传参
|
|||
|
|
var data = {
|
|||
|
|
"tbName": tbName
|
|||
|
|
};
|
|||
|
|
return data;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
$('#kvFileinputModal').on("hidden.bs.modal", function() {
|
|||
|
|
$(this).removeData("bs.modal");
|
|||
|
|
//modal重复打开会导致前面的滚动条失去作用
|
|||
|
|
$('.modal').css("overflow","auto");
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
//名称定义不可修改
|
|||
|
|
var getFileList = function() {
|
|||
|
|
$.post(ext.contextPath + '/base/getInputFileList.do', {masterId:masterId,tbName:tbName} , function(data) {
|
|||
|
|
//console.info(data)
|
|||
|
|
if(data.length>0){
|
|||
|
|
previews=new Array();
|
|||
|
|
// $('#maintenancefile').show();
|
|||
|
|
for(var i=0;i<data.length;i++){
|
|||
|
|
var previewConfig = new Object();
|
|||
|
|
var path = data[i].abspath;
|
|||
|
|
path=path.substring(path.indexOf('webapps')+7,path.length);
|
|||
|
|
path =ext.basePath.replace(ext.contextPath,'')+ path.replace(/\\/g,"\/");;
|
|||
|
|
previews.push(path);
|
|||
|
|
previewConfig['width']= '50px';
|
|||
|
|
previewConfig['caption']= data[i].filename;
|
|||
|
|
previewConfig['key']= data[i].id;
|
|||
|
|
previewConfigs.push(previewConfig);
|
|||
|
|
}
|
|||
|
|
showFileInput("efficiencyOverviewConfigureModelFile");
|
|||
|
|
}else{
|
|||
|
|
$('#efficiencyOverviewConfigureModelFile').hide();
|
|||
|
|
}
|
|||
|
|
},'json');
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
var fileinput = function() {
|
|||
|
|
//var url='/maintenance/updateProblemFile.do';//保存数据表方法
|
|||
|
|
$.post(ext.contextPath + '/base/fileinput.do', {masterId:masterId,tbName:tbName,nameSpace:nameSpace} , function(data) {
|
|||
|
|
$("#fileInputDiv").html(data);
|
|||
|
|
openModal('fileInputModal');
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
function doupdate() {
|
|||
|
|
$("#subForm").bootstrapValidator('validate');//提交验证
|
|||
|
|
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
|||
|
|
$.post(ext.contextPath + "/efficiency/efficiencyOverviewConfigure/doupdate.do", $("#subForm").serialize(), function(data) {
|
|||
|
|
if (data.code == 1){
|
|||
|
|
closeModal('subModal');
|
|||
|
|
$("#table").bootstrapTable('refresh');
|
|||
|
|
}else if(data.code == 0){
|
|||
|
|
showAlert('d','保存失败');
|
|||
|
|
}else{
|
|||
|
|
showAlert('d',data.res);
|
|||
|
|
}
|
|||
|
|
},'json');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//输入框验证
|
|||
|
|
$("#subForm").bootstrapValidator({
|
|||
|
|
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
|||
|
|
fields: {
|
|||
|
|
name: {
|
|||
|
|
validators: {
|
|||
|
|
notEmpty: {
|
|||
|
|
message: '名称不能为空'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//获取url地址根目录 当前taomcat下路径
|
|||
|
|
function getRootPath(){
|
|||
|
|
var pathName = window.location.pathname.substring(1);
|
|||
|
|
// var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
|
|||
|
|
return window.location.protocol + '//' + window.location.host;
|
|||
|
|
}
|
|||
|
|
var picId="";
|
|||
|
|
function showImg(){
|
|||
|
|
$('#mpConfigure').html("");
|
|||
|
|
$.post(ext.contextPath + '/base/getInputFileList.do', {masterId:masterId,tbName:tbName} , function(data) {
|
|||
|
|
if(data!=''){
|
|||
|
|
var abspath=data[0].abspath.split('webapps');
|
|||
|
|
picId=data[0].id;
|
|||
|
|
//document.getElementById("imgShow").src = ""+getRootPath()+""+abspath[1]+"";
|
|||
|
|
canvas = document.getElementById("canvas");
|
|||
|
|
context = canvas.getContext('2d');
|
|||
|
|
beauty = new Image();
|
|||
|
|
beauty.src = ""+getRootPath()+""+abspath[1]+"";
|
|||
|
|
// width = $(window).width();
|
|||
|
|
// height = $(window).height();
|
|||
|
|
width = beauty.width;
|
|||
|
|
height = beauty.height;
|
|||
|
|
if(beauty.complete){
|
|||
|
|
document.getElementById('canvas').width=beauty.width;
|
|||
|
|
document.getElementById('canvas').height=beauty.height;
|
|||
|
|
drawBeauty();
|
|||
|
|
mPointData(masterId);
|
|||
|
|
}else{
|
|||
|
|
beauty.onload = function(){
|
|||
|
|
drawBeauty();
|
|||
|
|
mPointData(masterId);
|
|||
|
|
};
|
|||
|
|
beauty.onerror = function(){
|
|||
|
|
alert('加载失败,请重试');
|
|||
|
|
};
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},'json');
|
|||
|
|
}
|
|||
|
|
function mPointData(picId){
|
|||
|
|
$.post(ext.contextPath + '/efficiency/efficiencyOverviewMpConfigure/getJson.do', {picId:picId,unitId:'${efficiencyOverviewConfigure.unitid}'} , function(mpdata) {
|
|||
|
|
dataAll =mpdata;
|
|||
|
|
if(mpdata.length>0){
|
|||
|
|
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
|||
|
|
context.drawImage(beauty, 0, 0, width, height);
|
|||
|
|
context.save();
|
|||
|
|
for(var m=0;m<mpdata.length;m++){
|
|||
|
|
var divHtml = "";
|
|||
|
|
if(mpdata[m].efficiencyOverviewConfigureAssembly!=null){
|
|||
|
|
var assembly =mpdata[m].efficiencyOverviewConfigureAssembly;
|
|||
|
|
if(assembly.type!=null && assembly.type!=''){
|
|||
|
|
if(assembly.type=='heat'){
|
|||
|
|
//热力组件
|
|||
|
|
selectAssembly_Heat(mpdata[m]);
|
|||
|
|
}else if(assembly.type=='mpoint'){
|
|||
|
|
//测量点组件
|
|||
|
|
divHtml = selectAssembly_mpdata(mpdata[m]);
|
|||
|
|
}else if(assembly.type=='meter'){
|
|||
|
|
//电力表组件
|
|||
|
|
divHtml = selectAssembly_meter(mpdata[m]);
|
|||
|
|
}else if(assembly.type=='dataFrame'){
|
|||
|
|
//数据框组件
|
|||
|
|
divHtml = selectAssembly_dataFrame(mpdata[m]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
if(mpdata[m].mPoint != ''){
|
|||
|
|
//测量点组件
|
|||
|
|
divHtml = selectAssembly_mpdata(mpdata[m]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$('#mpConfigure').append(divHtml);
|
|||
|
|
$('#'+mpdata[m].id).draggable();
|
|||
|
|
}
|
|||
|
|
context.save();
|
|||
|
|
}
|
|||
|
|
},'json');
|
|||
|
|
}
|
|||
|
|
function editps(id){
|
|||
|
|
stopBubbleDefaultEvent();
|
|||
|
|
$.post(ext.contextPath + '/efficiency/efficiencyOverviewMpConfigure/doedit.do', {id:id} , function(data) {
|
|||
|
|
$("#mpDiv").html(data);
|
|||
|
|
openModal('subMpModal');
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function setdata() {
|
|||
|
|
// var contentdiv=$("#mpConfigure");
|
|||
|
|
var obj = document.getElementsByTagName("DIV");
|
|||
|
|
for(var i=0;i<obj.length;i++){
|
|||
|
|
if(obj[i].className.indexOf("moveDiv")>=0){
|
|||
|
|
// console.log("id" , obj[i].id);
|
|||
|
|
// console.log("x", obj[i].style.left);
|
|||
|
|
// console.log("y" , obj[i].style.top);
|
|||
|
|
$.post(ext.contextPath + '/efficiency/efficiencyOverviewMpConfigure/updateLayout.do', {id:obj[i].id , posx:obj[i].style.left , posy:obj[i].style.top,}, function(data) {
|
|||
|
|
|
|||
|
|
},'json');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$(function () {
|
|||
|
|
$("#type").select2({ minimumResultsForSearch: 10 }).val("${efficiencyOverviewConfigure.type}").trigger("change");
|
|||
|
|
showImg();
|
|||
|
|
showAssembly();
|
|||
|
|
});
|
|||
|
|
function showAssembly(){
|
|||
|
|
$.post(ext.contextPath + '/efficiency/efficiencyOverviewConfigureAssembly/getTreeJson.do', {unitId:'${efficiencyOverviewConfigure.unitid}'}, function (data){
|
|||
|
|
var htmlStr = "";
|
|||
|
|
if(data!=null && data!=undefined && data!=''){
|
|||
|
|
for(var i=0;i<data.length;i++){
|
|||
|
|
htmlStr += '<button type="button" class="btn btn-default btn-sm" onclick="addAssemblyFun(\''+data[i].id+'\');" ><i class="fa fa-plus"></i>'+data[i].text+'</button>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$("#assembly").html(htmlStr);
|
|||
|
|
},'json');
|
|||
|
|
};
|
|||
|
|
var addMPFun = function () {
|
|||
|
|
if(picId==''){
|
|||
|
|
showAlert('d','请先上传图片!');
|
|||
|
|
}else{
|
|||
|
|
$.post(ext.contextPath + '/efficiency/efficiencyOverviewMpConfigure/mpConfigure.do', {unitId:'${efficiencyOverviewConfigure.unitid}',picId:picId}, function (data){
|
|||
|
|
$("#mp4SelectDiv").html(data);
|
|||
|
|
openModal('MPointModel');
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
var addAssemblyFun = function (id) {
|
|||
|
|
if(picId==''){
|
|||
|
|
showAlert('d','请先上传图片!');
|
|||
|
|
}else{
|
|||
|
|
$.post(ext.contextPath + "/efficiency/efficiencyOverviewMpConfigure/doAssemblySave.do",{assembly:id, picId:masterId,unitId:'${efficiencyOverviewConfigure.unitid}'}, function(data) {
|
|||
|
|
showImg();
|
|||
|
|
},'json');
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
window.onload=function(){
|
|||
|
|
var canvas=document.getElementById("canvas");
|
|||
|
|
// canvas.width=1024;
|
|||
|
|
// canvas.height=768;//通过这两种方式也可以设置canvas的大小;
|
|||
|
|
var context=canvas.getContext("2d");
|
|||
|
|
}
|
|||
|
|
</script>
|
|||
|
|
<div class="modal fade" id="subModal">
|
|||
|
|
<div style="padding: 5px;">
|
|||
|
|
<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">
|
|||
|
|
<!-- 新增界面formid强制为subForm -->
|
|||
|
|
<form class="form-horizontal" id="subForm">
|
|||
|
|
<!-- 界面提醒div强制id为alertDiv -->
|
|||
|
|
<div id="alertDiv"></div>
|
|||
|
|
<div id="mp4SelectDiv"></div>
|
|||
|
|
<div id="mpDiv"></div>
|
|||
|
|
<input type="hidden" name="id" value= "${efficiencyOverviewConfigure.id}">
|
|||
|
|
<%-- <div class="form-group">
|
|||
|
|
<label class="col-sm-2 control-label">*类型</label>
|
|||
|
|
<div class="col-sm-6">
|
|||
|
|
<select class="form-control select2" id="type" name="type" style="width:200px">
|
|||
|
|
<option value="0">总览</option>
|
|||
|
|
<option value="1">热力图</option>
|
|||
|
|
</select>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="form-group">
|
|||
|
|
<label class="col-sm-2 control-label">图例最大值</label>
|
|||
|
|
<div class="col-sm-6">
|
|||
|
|
<input type="text" class="form-control" id="upperlimit" name ="upperlimit" placeholder="最大值" value="${efficiencyOverviewConfigure.upperlimit}" >
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="form-group">
|
|||
|
|
<label class="col-sm-2 control-label">图例最小值</label>
|
|||
|
|
<div class="col-sm-6">
|
|||
|
|
<input type="text" class="form-control" id="lowerlimit" name ="lowerlimit" placeholder="最小值" value="${efficiencyOverviewConfigure.lowerlimit}" >
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="form-group">
|
|||
|
|
<label class="col-sm-2 control-label">图例层级</label>
|
|||
|
|
<div class="col-sm-6">
|
|||
|
|
<input type="text" class="form-control" id="grade" name ="grade" placeholder="层级" value="${efficiencyOverviewConfigure.grade}" >
|
|||
|
|
</div>
|
|||
|
|
</div> --%>
|
|||
|
|
<div class="form-group">
|
|||
|
|
<label class="col-sm-2 control-label">*名称</label>
|
|||
|
|
<div class="col-sm-3">
|
|||
|
|
<input type="text" class="form-control" id="name" name ="name" placeholder="名称" value="${efficiencyOverviewConfigure.name}" >
|
|||
|
|
</div>
|
|||
|
|
<label class="col-sm-2 control-label">排序</label>
|
|||
|
|
<div class="col-sm-3">
|
|||
|
|
<input type="text" class="form-control" id="morder" name ="morder" placeholder="排序" value="${efficiencyOverviewConfigure.morder}" >
|
|||
|
|
</div>
|
|||
|
|
<div class="col-sm-2">
|
|||
|
|
<button type="button" class="btn btn-default btn-file" onclick="fileinput()" id="btn_save"><i class="fa fa-paperclip"></i>上传图片</button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="form-group sidebar-nav">
|
|||
|
|
<div class="col-sm-1">
|
|||
|
|
<button type="button" class="btn btn-primary btn-sm" onclick="setdata();" ><i class="fa fa-save"></i> 保存布局</button>
|
|||
|
|
</div>
|
|||
|
|
<label class="col-sm-1 control-label">组件:</label>
|
|||
|
|
<div class="col-sm-10" id="assembly">
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<!-- <div style="height: 40px;">
|
|||
|
|
<button type="button" class="btn btn-default btn-sm" onclick="addMPFun();"><i class="fa fa-plus"></i>添加测量点</button>
|
|||
|
|
<button type="button" class="btn btn-default btn-sm" onclick="setdata();"><i class="fa fa-save"></i> 保存布局</button>
|
|||
|
|
</div> -->
|
|||
|
|
<div class="demo" style="width: 100%;height:100%;overflow: auto;" >
|
|||
|
|
<div id="mpConfigure" style="position:relative;"></div>
|
|||
|
|
<canvas id="canvas"></canvas>
|
|||
|
|
</div>
|
|||
|
|
</form>
|
|||
|
|
</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="doupdate()" id="btn_update">保存</button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<!-- /.modal-content -->
|
|||
|
|
</div>
|
|||
|
|
<!-- /.modal-dialog -->
|
|||
|
|
</div>
|