/** 根据班组信息返回班组信息和图片资源信息 @param string cname 班组名称 @param string cfile 班组名称拼音简写 @param return 返回班组信息和图片URL的对象 */ function getMapImageUrl(cname, cfile) { var rs = new Object(); // 结果对象 rs.chart_file = cfile; // 班组简写 rs.chart_name = cname; // 班组名称 console.info(cfile); // "User_ChartAction!serchByInfo?json={Chart_file:'+root+',Chart_name:chart_logo}" rs.logo = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_logo}"; // 班组logo rs.normal = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_normal}"; // 普通机房图标 rs.behind = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_behind}"; // 落后图标 rs.timeout = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_timeout}"; // 延时机房图标 rs.warn = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_warn}"; // 告警机房图标 rs.powercut = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_poff}"; // 停电机房图标 rs.xuhang = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:Chart_xuhang}"; // 续航不足机房图标 rs.installed = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_install}"; // 未安装图标 // 61850设备状态 rs.nuclear = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_nuclear_cap}"; rs.devalarm = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_dev_alarm}"; rs.precharge = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_pre_charge}"; rs.float = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_online_charge}"; return rs; } /** 根据班组信息的显示弹出框内容 @param object groupData 班组名称和班组的名称的拼音简写 */ function changePopup(groupData) { var chart_name = groupData.Chart_name; // 班组名称 var chart_file = groupData.Chart_file; // 班组简写 var imgList = getMapImageUrl(chart_name, chart_file); // 班组信息和图片资源信息 // 隐藏添加的文本框 $('.popup .add-list').hide(); // 更改弹出框图片的显示 $('.popup .logo').attr('src', imgList.logo); $('.popup .img-normal').attr('src', imgList.normal); $('.popup .img-behind').attr('src', imgList.behind); $('.popup .img-warn').attr('src', imgList.warn); $('.popup .img-timeout').attr('src', imgList.timeout); $('.popup .img-powercut').attr('src', imgList.powercut); $('.popup .img-xuhang').attr('src', imgList.xuhang); $('.popup .img-installed').attr('src', imgList.installed); // 61850设备状态 $('.popup .img-nuclear').attr('src', imgList.nuclear); $('.popup .img-devalarm').attr('src', imgList.devalarm); $('.popup .img-precharge').attr('src', imgList.precharge); $('.popup .img-float').attr('src', imgList.float); $('.popup .ensure-btn').addClass('edit-btn').removeClass('add-btn disabled'); // 更改表单中班组名称和班组名称拼音简写的文本框的值 $('#up-form input').val(""); // 清空form表单中input的值 $('#Chart_file').val(imgList.chart_file); $('#Chart_name').val(imgList.chart_name); popup.showPopup(); } // 添加工作班组 function addGroup() { // 显示添加的文本框 $('.popup .add-list').show(); $('.popup .logo').attr('src', 'images/none.jpg'); $('.popup .img-normal').attr('src', 'images/none.jpg'); $('.popup .img-behind').attr('src', 'images/none.jpg'); $('.popup .img-warn').attr('src', 'images/none.jpg'); $('.popup .img-timeout').attr('src', 'images/none.jpg'); $('.popup .img-powercut').attr('src', 'images/none.jpg'); $('.popup .img-xuhang').attr('src', 'images/none.jpg'); $('.popup .img-installed').attr('src', 'images/none.jpg'); // 61850设备状态图标 $('.popup .img-nuclear').attr('src', 'images/none.jpg'); $('.popup .img-devalarm').attr('src', 'images/none.jpg'); $('.popup .img-precharge').attr('src', 'images/none.jpg'); $('.popup .img-float').attr('src', 'images/none.jpg'); $('.popup .ensure-btn').addClass('disabled').removeClass('edit-btn add-btn'); $('#up_add_form input').val(""); // 清空form表单中input的值 popup.showPopup(); } // 检测按钮是否有edit-btn的class function checkEnsureBtn() { var rs = false; if($('.popup .ensure-btn').hasClass('edit-btn')) { rs = true; } return rs; } //选择图片,马上预览 function xmTanUploadImg(obj, ele, imgStr) { var file = obj.files[0]; var _imgStr = getImgSrc(imgStr); if(file == undefined) { ele.attr('src', _imgStr); return; } console.log(obj);console.log(file); console.log("file.size = " + file.size); //file.size 单位为byte var reader = new FileReader(); reader.onload = function (e) { ele.attr('src', e.target.result); //console.info(this.result); } reader.readAsDataURL(file); } // 添加上传图片预览 function addUploadImg(obj, ele) { var file = obj.files[0]; var _imgStr = getImgSrc(); if(file == undefined) { $('.popup .ensure-btn').addClass('disabled').removeClass('edit-btn add-btn'); ele.attr('src', _imgStr); return; } console.log(obj);console.log(file); console.log("file.size = " + file.size); //file.size 单位为byte var reader = new FileReader(); reader.onload = function (e) { ele.attr('src', e.target.result); isCanAdd(); } reader.readAsDataURL(file); } // 判断是否给添加按钮添加可点击事件 function isCanAdd() { var _chart_file = $('#add_chart_file').val().trim().length; var _chart_name = $('#add_chart_name').val().trim().length; var _logo = $('#file_add_logo').val().length; var _normal = $('#file_add_normal').val().length; var _behind = $('#file_add_behind').val().length; var _warn = $('#file_add_warn').val().length; var _timeout = $('#file_add_timeout').val().length; // 61850设备 if(_chart_file&&_chart_name&&_logo&&_normal&&_behind&&_warn&&_timeout) { $('.popup .ensure-btn').addClass('add-btn').removeClass('disabled'); }else { $('.popup .ensure-btn').addClass('disabled').removeClass('add-btn'); } } // 获取更改图标的集合 function getChangeImgList () { var rs = new Object(); rs.chart_file = $('#Chart_file').val(); rs.count = 0; var logo = $('.popup .logo').attr('src'); var normal = $('.popup .img-normal').attr('src'); var behind = $('.popup .img-behind').attr('src'); var warn = $('.popup .img-warn').attr('src'); var timeout = $('.popup .img-timeout').attr('src'); var powercut = $('.popup .img-powercut').attr('src'); var xuhang = $('.popup .img-xuhang').attr('src') var installed = $('.popup .img-installed').attr('src'); // 61850设备 var nuclear = $('.popup .img-nuclear').attr('src'); var _devalarm = $('.popup .img-devalarm').attr('src'); var precharge = $('.popup .img-precharge').attr('src'); var float = $('.popup .img-float').attr('src'); // 验证图片地址是否为base64 if(pregImgSrc(logo)) { // 班组logo rs.logo = logo; rs.count ++; } // 地图普通图标 if(pregImgSrc(normal)) { rs.normal = normal; rs.count ++; } // 地图落后图标 if(pregImgSrc(behind)) { rs.behind = behind; rs.count ++; } // 地图告警图标 if(pregImgSrc(warn)) { rs.warn = warn; rs.count ++; } // 地图延时图标 if(pregImgSrc(timeout)) { rs.timeout = timeout; rs.count ++; } // 地图停电图标 if(pregImgSrc(powercut)) { rs.powercut = powercut; rs.count ++; } // 续航不足图标 if(pregImgSrc(xuhang)) { rs.xuhang = xuhang; rs.count ++; } // 地图未安装图标 if(pregImgSrc(installed)) { rs.installed = installed; rs.count ++; } // 地图61850核容图标 if(pregImgSrc(nuclear)) { rs.nuclear = nuclear; rs.count ++; } // 地图61850预充电图标 if(pregImgSrc(_devalarm)) { rs.devalarm = _devalarm; rs.count ++; } // 地图61850告警图标 if(pregImgSrc(precharge)) { rs.precharge = precharge; rs.count ++; } // 地图61850浮充图标 if(pregImgSrc(float)) { rs.float = float; rs.count ++; } return rs; } /** * 验证图片是base64编码还是文件路径 * @param string src 图片的路径 */ function pregImgSrc(src) { var pattern = /^data:image/; return pattern.test(src); } /* * 根据弹出框的隐藏文本域中的Chart_file的值和函数的参数返回图片的src * @param string param 文本字符串 */ function getImgSrc(param) { var cfile = $('#Chart_file').val(); var rs = 'images/none.jpg'; if(param == undefined || cfile.lengh==0) { return rs; } switch(param) { case 'logo': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_logo}"; break; case 'normal': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_normal}"; break; case 'behind': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_behind}"; break; case 'timeout': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_timeout}"; break; case 'warn': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_warn}"; break; case 'powercut': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_poff}"; break; case 'xuhang': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:Chart_xuhang}"; break; case 'installed': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_install}"; break; // 61850设备状态 case 'nuclear': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_nuclear_cap}"; break; case 'devalarm': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_dev_alarm}"; break; case 'precharge': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_pre_charge}"; break; case 'float': rs = "User_ChartAction!serchByInfo?json={Chart_file:'"+cfile+"',Chart_name:chart_online_charge}"; break; default: rs = 'images/none.jpg'; } return rs; }