| | |
| | | // 设置容器的宽度
|
| | | _prop.setContainer = function() {
|
| | | var eleWidth = this.ele.width();
|
| | | this.container.width(eleWidth+20);
|
| | | //this.container.width(eleWidth+20);
|
| | | };
|
| | |
|
| | | // 生成列表
|
| | |
| | | var _data = $.extend({}, defaults, data[i]);
|
| | | // 设置内容容器
|
| | | var _li = $('<li></li>');
|
| | | var _a = $('<a href="javascript:;" class="sider-menu-folder"></a>');
|
| | | var _a = $('<a href="javascript:;" id="'+_data.id+'" class="sider-menu-folder"></a>');
|
| | | var _i = $('<i class="fa fa fa-caret-right"></i>');
|
| | | var _span = $('<span class="treeview-txt">'+_data.txt+'</span>');
|
| | | if(_data.file) {
|
| | |
| | | };
|
| | |
|
| | | // 获取folder的一条数据
|
| | | _prop.getFolder = function (txt, cla,attr) {
|
| | | _prop.getFolder = function (txt, cla, id,attr) {
|
| | | var tmp = {};
|
| | | tmp.txt = txt;
|
| | | tmp.cla = cla;
|
| | | tmp.id = id;
|
| | | tmp.attr = attr;
|
| | | return tmp;
|
| | | };
|
| | |
| | | }
|
| | | var tgt = aFolders.eq(0);
|
| | | aFolders.each(function() {
|
| | | var _txt = $(this).find('.treeview-txt').text();
|
| | | var _txt = $(this).find('.treeview-txt').parent().attr('id');
|
| | | if(txt == _txt) {
|
| | | tgt = $(this);
|
| | | }
|
| | |
| | |
|
| | | };
|
| | |
|
| | | _prop.activeFile = function(cla, txt, callback) {
|
| | | _prop.activeFile = function(container, cla, id, callback) {
|
| | | var rsCla = '.sider-menu-file'+'.'+cla;
|
| | | var aFiles = this.ele.find(rsCla);
|
| | | var aFiles = container.find(rsCla);
|
| | | //console.log(aFiles.length);
|
| | | // 没有获取到内容就返回false
|
| | | if(aFiles.length == 0) {
|
| | | return false;
|
| | | }
|
| | | var tgt = aFiles.eq(0);
|
| | | |
| | | // 遍历列表
|
| | | aFiles.each(function() {
|
| | | var _id = $(this).attr('id');
|
| | | // id匹配
|
| | | if(_id == id) {
|
| | | tgt = $(this);
|
| | | }
|
| | | });
|
| | | |
| | | tgt.click();
|
| | | };
|
| | |
|
| | |
| | | // 获取当前选中内容(省-市-机房-电池组)
|
| | | var province = getQueryString('province'); // 省
|
| | | var city = getQueryString('city'); // 市
|
| | | var county = getQueryString('county'); // 区/县
|
| | | var home = getQueryString('home'); // 机房
|
| | | |
| | | console.log(province);
|
| | | var homeid = getQueryString('homeid'); // 电池组id
|
| | | //console.log(province);
|
| | |
|
| | | // 生成一级导航-省
|
| | | function first(treeView, container) {
|
| | |
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFolder(__data.StationName1, 'province', __data);
|
| | | var tmp = treeView.getFolder(__data.StationName1, 'province', __data.StationName1,__data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | |
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFolder(__data.StationName2, 'city', __data);
|
| | | var tmp = treeView.getFolder(__data.StationName2, 'city', __data.StationName2, __data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | |
| | | }
|
| | |
|
| | |
|
| | | // 生成 三级导航-机房
|
| | | // 生成 三级导航-区/县
|
| | | function third(treeView, container, data, spread) {
|
| | | // 已经存在
|
| | | if(container.find('ul').length !=0) {
|
| | |
| | | treeView.addProgress(container);
|
| | | $.ajax({
|
| | | type: "post",
|
| | | url: "BattInfAction!serchStationName3", |
| | | url: "BattInfAction!serchStationName5", |
| | | async:true,
|
| | | dataType:'json',
|
| | | data:"json = "+JSON.stringify(data),
|
| | |
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFolder(__data.StationName, 'home', __data);
|
| | | var tmp = treeView.getFolder(__data.StationName5, 'county', __data.StationName5,__data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | | if(spread) {
|
| | | treeView.spreadFolder('home', home, thirdSpread, true);
|
| | | treeView.spreadFolder('county', county, thirdSpread, true);
|
| | | }
|
| | | }else {
|
| | |
|
| | |
| | | var tmp = {
|
| | | StationName1: data.StationName1,
|
| | | StationName2: data.StationName2,
|
| | | StationName: data.StationName,
|
| | | StationId: data.StationId
|
| | | StationName5: data.StationName5,
|
| | | };
|
| | | fourth(treeView, container, tmp, true);
|
| | | }
|
| | |
|
| | |
|
| | | // 生成 三级导航-机房
|
| | | // 生成 三级导航-区/县
|
| | | function thirdFile(treeView, container, data) {
|
| | | // 已经存在
|
| | | if(container.find('ul').length !=0) {
|
| | | return;
|
| | | }
|
| | | treeView.addProgress(container);
|
| | | $.ajax({ |
| | | type: "post", |
| | | url: "BattInfAction!serchStationName5", |
| | | async:true, |
| | | dataType:'json',
|
| | | data:"json = "+JSON.stringify(data), |
| | | success: function(data){
|
| | | var rs = JSON.parse(data.result);
|
| | | treeView.delProgress(container);
|
| | | if(rs.code == 1) {
|
| | | var _data= rs.data;
|
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFile(__data.StationName5, 'county', '',__data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | | }else {
|
| | | |
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | // 将函数绑定到GLOBAL.pages.siderbar的命名空间下
|
| | | gl.pages.siderbar.thirdFile = thirdFile;
|
| | | |
| | | //生成四级导航-机房
|
| | | function fourth(treeView, container, data, spread) {
|
| | | // 已经存在
|
| | | if(container.find('ul').length !=0) {
|
| | | return;
|
| | |
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFile(__data.StationName, 'home', '',__data);
|
| | | var tmp = treeView.getFolder(__data.StationName3, 'home', __data.StationName,__data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | | if(spread) {
|
| | | treeView.spreadFolder('home', home, fourthSpread, true);
|
| | | }
|
| | | }else {
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 将函数绑定到GLOBAL.pages.siderbar的命名空间下
|
| | | gl.pages.siderbar.thirdFile = thirdFile;
|
| | | gl.pages.siderbar.fourth = fourth;
|
| | |
|
| | | // 生成 三级导航-电池组
|
| | | function fourth(treeView, container, data, active) {
|
| | | // 展开四级导航
|
| | | function fourthSpread(treeView, container, data) {
|
| | | var tmp = {
|
| | | StationName1: data.StationName1,
|
| | | StationName2: data.StationName2,
|
| | | StationName5: data.StationName5,
|
| | | StationName: data.StationName,
|
| | | StationId: data.StationId
|
| | | };
|
| | | fifth(treeView, container, tmp, true);
|
| | | }
|
| | | |
| | | // 生成五级导航-电池组
|
| | | function fifth(treeView, container, data, active) {
|
| | | // 已经存在
|
| | | if(container.find('ul').length !=0) {
|
| | | return;
|
| | |
| | | treeView.treeView(container, formatData);
|
| | | //console.info(formatData);
|
| | | if(active) {
|
| | | treeView.activeFile('eleGroup', '');
|
| | | treeView.activeFile(container,'eleGroup', homeid);
|
| | | var battId = formatData[0].id;
|
| | | location.hash="#"+battId;
|
| | | location.hash = "";
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | | // 将函数绑定到GLOBAL.pages.siderbar的命名空间下
|
| | | gl.pages.siderbar.fifth = fifth;
|
| | | })(jQuery, window, document, GLOBAL);
|
| | |
|
| | |
|
| | | // 设置根据省市机房和电池进行定位
|
| | | ;(function($, window, document, gl, undefined) {
|
| | | gl.namespace('pages.siderbar');
|
| | | |
| | | var homeInfo = {
|
| | | StationName1: '',
|
| | | StationName2: '',
|
| | | StationName: '',
|
| | | StationId: ''
|
| | | };
|
| | | |
| | | var battId=undefined;
|
| | | |
| | | // 定位机房
|
| | | function localSideBar(treeView, container, data) {
|
| | | // 关闭所有的
|
| | | treeView.ele.find('li').removeClass('sider-menu-open');
|
| | | |
| | | |
| | | first(treeView, container);
|
| | | homeInfo.StationName1 = data.province;
|
| | | homeInfo.StationName2 = data.city;
|
| | | homeInfo.StationName5 = data.county;
|
| | | homeInfo.StationName = data.home;
|
| | | homeInfo.StationId = data.homeid;
|
| | | battId = data.battid;
|
| | | }
|
| | |
|
| | | // 将函数绑定到GLOBAL.pages.siderbar的命名空间下
|
| | | gl.pages.siderbar.fourth = fourth;
|
| | | })(jQuery, window, document, GLOBAL); |
| | | gl.pages.siderbar.localSideBar = localSideBar;
|
| | | |
| | | // 生成一级导航-省
|
| | | function first(treeView, container) {
|
| | | //treeView.addProgress(container);
|
| | | $.ajax({ |
| | | type: "post", |
| | | url: "BattInfAction!serchAllStation", |
| | | async:true, |
| | | dataType:'json',
|
| | | data:null, |
| | | success: function(data){
|
| | | var rs = JSON.parse(data.result);
|
| | | if(rs.code == 1) {
|
| | | var _data= rs.data;
|
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFolder(__data.StationName1, 'province', __data.StationName1,__data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | | treeView.spreadFolder('province', homeInfo.StationName1, firstSpread);
|
| | | }else {
|
| | | |
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | // 展开一级导航
|
| | | function firstSpread(treeView, container) {
|
| | | second(treeView, container, homeInfo, true);
|
| | | }
|
| | | |
| | | |
| | | // 生成二级导航-市
|
| | | function second(treeView, container, data, spread) {
|
| | | // 已经存在
|
| | | if(container.find('ul').length !=0) {
|
| | | treeView.spreadFolder('city', homeInfo.StationName2, secondSpread, true);
|
| | | return;
|
| | | }
|
| | | treeView.addProgress(container);
|
| | | $.ajax({ |
| | | type: "post", |
| | | url: "BattInfAction!serchStationName2", |
| | | async:true, |
| | | dataType:'json',
|
| | | data:"json = "+JSON.stringify(data), |
| | | success: function(data){
|
| | | var rs = JSON.parse(data.result);
|
| | | treeView.delProgress(container);
|
| | | if(rs.code == 1) {
|
| | | var _data= rs.data;
|
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFolder(__data.StationName2, 'city', __data.StationName2, __data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | | |
| | | if(spread) {
|
| | | treeView.spreadFolder('city', homeInfo.StationName2, secondSpread);
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | // 展开二级导航
|
| | | function secondSpread(treeView, container) {
|
| | | third(treeView, container, homeInfo, true);
|
| | | }
|
| | | |
| | | |
| | | // 生成 三级导航-区/县
|
| | | function third(treeView, container, data, spread) {
|
| | | // 已经存在
|
| | | if(container.find('ul').length !=0) {
|
| | | location.hash="#"+homeInfo.StationName5;
|
| | | location.hash="";
|
| | | treeView.spreadFolder('county', homeInfo.StationName5, thirdSpread, true);
|
| | | return;
|
| | | }
|
| | | treeView.addProgress(container);
|
| | | $.ajax({ |
| | | type: "post", |
| | | url: "BattInfAction!serchStationName5", |
| | | async:true, |
| | | dataType:'json',
|
| | | data:"json = "+JSON.stringify(data), |
| | | success: function(data){
|
| | | var rs = JSON.parse(data.result);
|
| | | treeView.delProgress(container);
|
| | | if(rs.code == 1) {
|
| | | var _data= rs.data;
|
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFolder(__data.StationName5, 'county', __data.StationName5, __data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | | if(spread) {
|
| | | location.hash="#"+homeInfo.StationName5;
|
| | | location.hash="";
|
| | | treeView.spreadFolder('county', homeInfo.StationName5, thirdSpread, true);
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | // 展开三级导航
|
| | | function thirdSpread(treeView, container, data) {
|
| | | fourth(treeView, container, homeInfo, true);
|
| | | }
|
| | | |
| | | // 生成 四级导航-机房
|
| | | function fourth(treeView, container, data, spread) {
|
| | | // 已经存在
|
| | | if(container.find('ul').length !=0) {
|
| | | location.hash="#"+homeInfo.StationName;
|
| | | location.hash="";
|
| | | treeView.spreadFolder('home', homeInfo.StationName, fourthSpread, true);
|
| | | return;
|
| | | }
|
| | | treeView.addProgress(container);
|
| | | $.ajax({ |
| | | type: "post", |
| | | url: "BattInfAction!serchStationName3", |
| | | async:true, |
| | | dataType:'json',
|
| | | data:"json = "+JSON.stringify(data), |
| | | success: function(data){
|
| | | var rs = JSON.parse(data.result);
|
| | | treeView.delProgress(container);
|
| | | if(rs.code == 1) {
|
| | | var _data= rs.data;
|
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFolder(__data.StationName3, 'home', __data.StationName, __data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | | if(spread) {
|
| | | location.hash="#"+homeInfo.StationName;
|
| | | location.hash="";
|
| | | treeView.spreadFolder('home', homeInfo.StationName, fourthSpread, true);
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | |
| | | // 展开三级导航
|
| | | function fourthSpread(treeView, container, data) {
|
| | | fifth(treeView, container, homeInfo, true);
|
| | | }
|
| | | |
| | | |
| | | |
| | | // 生成 五级导航-电池组
|
| | | function fifth(treeView, container, data, active) {
|
| | | // 已经存在
|
| | | if(container.find('ul').length !=0) {
|
| | | container.addClass('sider-menu-open');
|
| | | if(battId) {
|
| | | treeView.activeFile(container,'eleGroup', battId);
|
| | | }else {
|
| | | treeView.activeFile(container,'eleGroup', '');
|
| | | }
|
| | | return;
|
| | | }
|
| | | treeView.addProgress(container);
|
| | | $.ajax({ |
| | | type: "post", |
| | | url: "BattInfAction!serchBattByStation", |
| | | async:true, |
| | | dataType:'json',
|
| | | data:"json = "+JSON.stringify(data), |
| | | success: function(data){
|
| | | var rs = JSON.parse(data.result);
|
| | | treeView.delProgress(container);
|
| | | if(rs.code == 1) {
|
| | | var _data= rs.data;
|
| | | //console.log(_data);
|
| | | var formatData = [];
|
| | | for(var i=0; i<_data.length;i++) {
|
| | | var __data = _data[i];
|
| | | var tmp = treeView.getFile(__data.BattGroupName, 'eleGroup', __data.BattGroupId, __data);
|
| | | formatData.push(tmp);
|
| | | }
|
| | | treeView.treeView(container, formatData);
|
| | | if(active) {
|
| | | if(battId) {
|
| | | treeView.activeFile(container,'eleGroup', battId);
|
| | | location.hash="#"+battId;
|
| | | location.hash="";
|
| | | }else {
|
| | | treeView.activeFile(container,'eleGroup', '');
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | })(jQuery, window, document, GLOBAL);
|
| | |
|
| | | //生成充放电监测模块内容
|
| | | function createBattListen(ele, list) {
|
| | | ele.text("");
|
| | | var discharge_num = 0;
|
| | | var charge_num = 0;
|
| | | var ul = $('<ul></ul>');
|
| | | for(var i = 0; i < list.length; i++) {
|
| | | var li = "";
|
| | | if(list[i].isCharge) {
|
| | | li = $('<li><a href="javascript:;" class="batt-charge" value="'+list[i].val+'" note="'+list[i].note+'">'+list[i].val+'电池组充电测试!</a></li>');
|
| | | charge_num++;
|
| | | }else {
|
| | | li = $('<li><a href="javascript:;" class="batt-discharge" value="'+list[i].val+'" note="'+list[i].note+'">'+list[i].val+'电池组放电测试!</a></li>');
|
| | | discharge_num++;
|
| | | }
|
| | | |
| | | li.data('attr', list[i]);
|
| | | ul.append(li);
|
| | | |
| | | }
|
| | | |
| | | $('#ele_content .batt-listen .count-num').find('span').eq(0).text(discharge_num);
|
| | | $('#ele_content .batt-listen .count-num').find('span').eq(1).text(charge_num);
|
| | | ele.append(ul);
|
| | | } |