var treeData = new Array(); $(function(){ queryAllChannelApiContor(); //console.info(Commonjs.getJscrollpane); Commonjs.getJscrollpane.destroy(); }); //获取数据 function queryAllChannelApiContor(){ var param = {}; param.Api = "queryAllChannelApiContor"; param.Params = ''; var d = Commonjs.ajax('./channel_doAll.do',param,false); if(d.RespCode != 10000){ Commonjs.alert(d.RespMessage); $(window).html(''); }else{ initData(d.Result); $('#treeUL').empty().append(initTreeHtml(treeData,-1)); } } function loadCallTimes(){ var apis = $('#apis').val(); var pname = $('#pname').val(); if(Commonjs.isEmpty(pname) && Commonjs.isEmpty(apis)){ $("#dataList tr").eq(0).nextAll().remove(); return ; } else apis = getChannelIDSByType(pname,apis); var param = {}; param.Api = "queryChannelApiContorByChannelIDS"; param.Params = '{"apis":"'+apis+'"}'; var d = Commonjs.ajax('./channel_doAll.do',param,false); initTableHtml(d.Result); } function getChannelIDSByType(pname,id){ var ids = null; if(id != null){ return id; }else{ $.each(d,function(i,it){ $.each(it.data,function(i,sit){ if(sit.name == type){ ids += sit.id+','; } }) }) } } function showFolw(pid,name,api){ $('#apis').val(''); if(!Commonjs.isEmpty(api)){ $('#apis').val(api); } else{ var apis = ''; $.each(treeData,function(i,it){ if(it.id == pid){ $.each(it.data,function(j,pit){ $.each(pit.data,function(k,sit){ if(pit.name == name){ apis += sit.key+','; } }) }) } }) $('#apis').val(apis); } loadCallTimes(); } function initTableHtml(d){ var html = ''; $.each(d,function(i,it){ html += ''+it.channelname+'/'+it.apiname+'' +it.mmtimes+''+it.hhtimes+''+it.hhtimes+''; }) $("#dataList tr").eq(0).nextAll().remove(); $(html).insertAfter($("#dataList tr").eq(0)); } function initTreeHtml(d,pid){ var html = ''; if(pid != -1){// if(!Commonjs.isEmpty(d)){ $.each(d,function(i,it){ if(it.pid == pid){ if(d.length == (i+1)) { html += '
  • '; }else{ html += '
  • '; } html += '
    '+it.name+'
    '; html += '
  • '; } }) } }else{//根节点 if(!Commonjs.isEmpty(d)){ $.each(d,function(i,it){ if(it.channelid == '100123'){ if(it.id == d.length-1){ html += '
  • '; }else html += '
  • '; html += '
    '+it.name+'
    '; }else if(it.channelid == '100126'){ if(it.id == d.length-1){ html += '
  • '; }else html += '
  • '; html += '
    '+it.name+'
    '; }else if(it.channelid == '100125'){ if(it.id == d.length-1){ html += '
  • '; }else html += '
  • '; html += '
    '+it.name+'
    '; }else { if(it.id == d.length-1){ html += '
  • '; }else html += '
  • '; html += '
    '+it.name+'
    '; } html += '
  • '; }) } } return html; } /** * 格式转化 */ function initData(d){ var gp_arr = new Array(); var p_arr = new Array(); var s_arr = new Array(); var p_index = 0; var p_temp = new Array(); var s_temp = new Array(); $.each(d,function(i,it){//GP var gp = {}; gp.key = it.keypassword; gp.name = it.channelname; gp.id = i; gp.pid = 0; gp.data = new Array(); var p_arr = new Array(); //第二层 $.each(it.channelApiContors,function(k,pit){//P var p = {}; p.name = pit.sysname; p.id = k; p.pid = i; p.data = new Array(); if(isNotPDExists(p_temp,i,p.name)){// var tp = {}; tp.name = p.name; tp.id = i; p_temp.push(tp); gp.channelid = pit.channelid; //第3层 $.each(it.channelApiContors,function(j,sit){//s var s = {}; s.name = sit.apiname; s.key = sit.api; s.pid = k; s.data = null; if(p.name == sit.sysname && isNotSDExists(s_temp,s.name)){// s_temp.push(s.name); p.data.push(s); } }) gp.data.push(p); } }) treeData.push(gp); }) } function isNotSDExists(s,name){ if(s.length == 0){ return true; }else{ for(var i=0;i