var self; var type, level, area, title,sort=1,banerIndex; var roleLevel, userRole; var startDate = null;//近3月的开始时间 var endDate = null;//近3月的结束时间 var customHeight = 63;//自定义折线图、柱状图混合表中各项的高度 var scroller1 = null; var old_back = mui.back; var curLeveArr = null;//当前级别需要请求的url参数集合 var lowCode; //记录选中其他维度的参数 var taskNum = 0;//任务量 var dateData = {};//趋势图数据 var isInit = true; var CITY_CODE = "350200";//默认厦门市 var TD_PAGE_SIZE = 20;//所有团队数据分页条数 var current_team_index = 0;//所有团队显示的索引值 var team_data_list = null;//所有团队数据(签约量) var team_name_list = null;//所有团队数据(名称) var team_top_list = null;//所有团队数据(排名数据) var team_scroller = null; var lineIndexArr = {1: 42, 2: 43, 3: 44, 4: 29}; //折线图中对应的index参数值 //定义年份 var chooseYear; var now = new Date(); if(now.getMonth() >= 6){ chooseYear = now.getFullYear(); }else{ chooseYear = now.getFullYear() - 1; } mui.plusReady(function() { self = plus.webview.currentWebview(); type = self.type; startDate = getStartDate(); endDate = getEndDate(); initData();//数据初始化 initScroller();//scroll初始化 shaixuanInit(self); bindEvents();//事件绑定 }); /*****************************************************************************/ /***** 页面初始化处理 **********/ /*****************************************************************************/ var initData = function(){ // userRole = plus!=null ?JSON.parse(plus.storage.getItem("userRole"))[0]:{} ; userRole = plus!=null ? JSON.parse(plus.storage.getItem("selectedRole")): {}; roleLevel = userRole.code == CITY_CODE ? 4 : userRole.code.length==6 ? 3 : 2; level = roleLevel; area = userRole.code; title = userRole.name; plus.storage.setItem("userLevel",level+""); plus.storage.setItem("userArea",area); //初始默认选中的时间和类型 $(".choose-label").text("(所有居民)"); //搜集页面请求的参数 var paramsArr = [],requestArr = []; var index = 29; //签入: 34, 签出: 35 if(level==4){//市管 paramsArr.push({tags:["各区","社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{ year: 2017,code:area,level:level, index: 29}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:29}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:44,area:area}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:43,area:area,lowLevel:2}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:42,area:area,lowLevel:1}}); }else if(level==3){//区管 paramsArr.push({tags:["社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:level, index: 44}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:44}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:43,area:area}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:42,area:area,lowLevel:1}}); }else if(level==2){//社区管 paramsArr.push({tags:["团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:level, index: 43}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:43}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:42,area:area}}); } requestArr.push(paramsArr); plus.storage.setItem("levelParamsArr",JSON.stringify(requestArr)); curLeveArr = paramsArr; loadAllData(paramsArr); }, loadAllData = function(arr){ plus.nativeUI.showWaiting(); //1-1:加载数据截止时间 sendPost("/statistics/time",null,function(res){ },function(res){ if(res.status=="200"){ var date = (res.data && res.data.substring(11,16)) || ""; $(".jiezhi-time").html(date) } }); //1-2: 显示title title = arr[0].curTitle; if(arr[0].level==4){ title = title.substring(0,3); } $("#title").html(title); //1-3 :加载tab var tagsArr = arr[0].tags; var tagStr = ""; for(var i=0;i'+tagsArr[i]+''; } $(".c-lab-mor").html(tagStr); $(".div-data-list").hide(); $(".div-data-list.div-list0").show(); if($(".c-lab-mor li.hit a").html()=="团队" || tagsArr.length==1){ $(".div-right-danwei").html("人"); }else{ $(".div-right-danwei").html("千人"); } var index = lineIndexArr[level]; //1-4 :加载签约率、完成率 // arr[1].params.index = index; sendGet(arr[1].reqUrl, arr[1].params, null, countHandle, true); //1-5:趋势图表 var interval = parseInt(arr[2].params.interval)-1 || 0; $('.div-btn-group .div-btn').removeClass("active"); $('.div-btn-group .div-btn').eq(interval).addClass("active"); // arr[2].params.index = index; sendPost(arr[2].reqUrl, arr[2].params, null, dateLineHandle); //1-6:加载【第一个】tab标签数据 // arr[3].params.index = index - 1; sendPost(arr[3].reqUrl, arr[3].params, null, listHandle); }, initScroller = function(){ window.scroller1 = $("#wrapper1").initScroll( { pullDownAction: function(){ current_team_index = 0; $(".pullDown").show(); plus.nativeUI.showWaiting(); loadAllData(curLeveArr); },pullUpAction: function() { $(".pullUp").hide(); if($(".c-lab-mor li.hit a").html()=="团队"){//团队tab页才做分页 if(current_team_index==(Object.keys(team_data_list).length-1)){ mui.toast("没有更多数据了..."); $(".pullUp").hide(); plus.nativeUI.closeWaiting(); return false; } $(".pullUp").show(); plus.nativeUI.showWaiting(); current_team_index++; loadTeamData(team_data_list[current_team_index],team_top_list[current_team_index],true); } return false; } } ); }, /** * 初始化筛选事件 */ shaixuanInit = function(main){ var shaixuan = plus.webview.getWebviewById('xq-shaixuan.html'); if(!shaixuan){ shaixuan = mui.createWindow({ id: 'xq-shaixuan.html', url: 'xq-shaixuan.html', styles: { top: 0, bottom: 0, left: '20%', width: '80%', scorllIndicator: "none" }, show:{ aniShow: "slide-in-right", duration: "400" }, extras:{ } }); } window.addEventListener("hideShaiXuan",function(){ console.log("hideShaiXuan"); main.setStyle({mask:"none"}); shaixuan.hide(); }, false); window.addEventListener("showShaiXuan", function() { shaixuan.show(); main.setStyle({mask:"rgba(0,0,0,0.5)"}); main.addEventListener("maskClick",function(){ main.setStyle({mask:"none"}); shaixuan.hide(); }, false); }); }, bindEvents = function(){ //标签切换 $(".c-lab-mor").on("tap","li",function(){ var liIndex = $(this).index(); var tabid = $(this).attr("id"); var top = $(this).offset().top; $(".c-lab-mor li").removeClass("hit"); $(this).addClass("hit"); var tabName = $(".c-lab-mor li.hit a").html(); //1-6:加载tab标签数据 if($(this).attr("data-click")=="false"){//tab数据未加载 plus.nativeUI.showWaiting(); var index ; if(tabName == "各区"){ // index = 29; // curLeveArr[3].params.index = index; sendPost(curLeveArr[3].reqUrl, curLeveArr[3].params, null, listHandle); }else if(tabName == "社区"){//社区数据 // index = 43; // curLeveArr[4].params.index = index; if(curLeveArr.length == 5){ sendPost(curLeveArr[3].reqUrl, curLeveArr[3].params, null, listHandle); }else{ sendPost(curLeveArr[4].reqUrl, curLeveArr[4].params, null, listHandle); } }else if(tabName == "团队"){//团队数据 // index = 42; // curLeveArr[5].params.index = index; if(curLeveArr.length == 6){ sendPost(curLeveArr[5].reqUrl, curLeveArr[5].params, null, listHandle); }else if(curLeveArr.length == 5){ sendPost(curLeveArr[4].reqUrl, curLeveArr[4].params, null, listHandle); }else{ sendPost(curLeveArr[3].reqUrl, curLeveArr[3].params, null, listHandle); } } $(this).attr("data-click","true"); } $(".div-data-list").hide(); $(".div-list"+liIndex).show(); $(".div-list1 li .div-name,.div-list1 li .div-amount,.div-list2 li .div-name,.div-list2 li .div-amount").each(function(){ if($(this).height()==21){ $(this).addClass("mt20") }else if($(this).height()==42){ $(this).addClass("mt10") } }) if($(".c-lab-mor li.hit a").html()=="团队"){ $(".div-right-danwei").html("人"); }else{ $(".div-right-danwei").html("千人"); } scroller1.refresh(); window.onscroll = function () { var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; if(top!=-1 && top>0){ window.scrollTo(0,top); top = -1; } } }); //日、周、月按钮切换 $(".div-btn-group").on("click",".div-btn",function(){ var dataId = $(this).attr("data-id"); $(".div-btn-group .div-btn").removeClass("active"); $(this).addClass("active"); //1-5:趋势图表 curLeveArr[2].params.interval = dataId; // curLeveArr[2].params.index = lineIndexArr[level]; sendPost(curLeveArr[2].reqUrl, curLeveArr[2].params, null, dateLineHandle); }); $(".scroll-wrapper").on("tap",".div-data-list .list-ul .div-name",function(event){ if($(".c-lab-mor li.hit a").html()=="团队") { sendGet("/doctor/admin-teams/teams/info",{teamId:$(this).closest("li").attr("data-code")},function(res){ },function(res){ if(res.status==200){ var team = res.data.team; var members = res.data.members; $(".span-name").html(team.name || ""); $(".span-hospitalName").html(team.hospitalName || ""); $(".span-leaderName").html(team.leaderName || ""); $(".span-team-count").html(members.length.toString()); var membersName = ""; for(var i=0;i20){ membersName = membersName!=""?membersName.substring(0,membersName.length-1)+"等":membersName; }else{ membersName = membersName!=""?membersName.substring(0,membersName.length-1):membersName; } $(".span-members").html(membersName); $(".modal-overlay").addClass("modal-overlay-visible"); setTimeout(function(){ $(".modal-content").show(); },50) }else{ mui.toast("暂无相关团队详情!"); } }); return false; } level = curLeveArr[0].level; level--; area = $(this).closest("li").attr("data-code"); var name = $(this).closest("li").attr("data-name"); title = name; $("#title").html(title); var paramsArr = []; var index = 29; if(!lowCode || lowCode=='0'){ if(level==3 && $(".c-lab-mor li.hit a").html()=="各区"){//区管 paramsArr.push({tags:["社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:level, index: 44}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:$('.div-btn-group .div-btn.active').attr('data-id'),index: 44}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:43,area:area}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:42,area:area,lowLevel:1}}); }else{//社区管 paramsArr.push({tags:["团队"],curTitle:title,level:2}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:2, index: 43}}, {reqUrl:"/statistics/interval_total",params:{level: 2, area: area, startDate: startDate, endDate: endDate, interval:$('.div-btn-group .div-btn.active').attr('data-id'),index:43}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:2,index:42,area:area}}); } }else{ if(level==3 && $(".c-lab-mor li.hit a").html()=="各区"){//区管 paramsArr.push({tags:["社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:level, index: 54, lowCode: lowCode}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:$('.div-btn-group .div-btn.active').attr('data-id'),index: 54, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:53,area:area, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:level,index:52,area:area,lowLevel:1, lowCode: lowCode}}); }else{//社区管 paramsArr.push({tags:["团队"],curTitle:title,level:2}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:2, index: 53, lowCode: lowCode}}, {reqUrl:"/statistics/interval_total",params:{level: 2, area: area, startDate: startDate, endDate: endDate, interval:$('.div-btn-group .div-btn.active').attr('data-id'),index:53, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,date:endDate,level:2,index:52,area:area, lowCode: lowCode}}); } } var existArr = JSON.parse(plus.storage.getItem("levelParamsArr")); existArr.push(paramsArr); plus.storage.setItem("levelParamsArr",JSON.stringify(existArr)); curLeveArr = paramsArr; current_team_index = 0; loadAllData(paramsArr); event.preventDefault(); return false; }); //转签率点击了进入续签分析页面 $("#zhuanqianWrap").on("tap", function(){ if(!lowCode || lowCode=='0'){ mui.openWindow({ url: "renew-analysis.html", id: "renew-analysis.html", extras:{ level:curLeveArr[0].level, code:area, title: title } }); } }) //说明信息相关事件 $("#closeBtn").on("tap", function(){ $(".information").hide(); scroller1.refresh(); }); $(".info-icon").on("tap", function(){ $(".information").show(); scroller1.refresh(); }); //弹出遮罩 $(".icon-remark").on("click", function(e) { $(".modal-overlay").addClass("modal-overlay-visible"); setTimeout(function(){ $(".modal-content").show(); },50) }); $(".div-close,.modal-overlay").on("click",function(){ $(".modal-overlay").removeClass("modal-overlay-visible"); $(".modal-content").hide(); }); //左滑筛选区域的数据 $('.header-link').on("tap", function(){ var self = plus.webview.currentWebview(); mui.fire(self, "showShaiXuan"); }); //添加页面监听 window.addEventListener("refresh", function(e){ lowCode = e.detail.lowCode; var name = e.detail.name; $(".choose-label").text("("+name+")"); level = roleLevel; area = userRole.code; title = userRole.name; var paramsArr = []; var index = 29; if(lowCode == '0'){ if(level==4){//市管 paramsArr.push({tags:["各区","社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{ year: 2017,code:area,level:level, index: 29}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:29}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:44,area:area}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:43,area:area,lowLevel:2}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:42,area:area,lowLevel:1}}); }else if(level==3){//区管 paramsArr.push({tags:["社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:level, index: 44}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:44}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:43,area:area}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:42,area:area,lowLevel:1}}); }else if(level==2){//社区管 paramsArr.push({tags:["团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:level, index: 43}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:43}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:42,area:area}}); } }else{ var index = 51; //签入: 34, 签出: 35 if(level==4){//市管 paramsArr.push({tags:["各区","社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{ year: 2017,code:area,level:level, index: 51, lowCode: lowCode}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:51, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:54,area:area, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:53,area:area,lowLevel:2, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:52,area:area,lowLevel:1, lowCode: lowCode}}); }else if(level==3){//区管 paramsArr.push({tags:["社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:level, index: 54, lowCode: lowCode}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:54, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:53,area:area, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:52,area:area,lowLevel:1, lowCode: lowCode}}); }else if(level==2){//社区管 paramsArr.push({tags:["团队"],curTitle:title,level:level}, {reqUrl:"/statistics/getRenewPercentAndChangePercent",params:{year: 2017,code:area,level:level, index: 53, lowCode: lowCode}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:53, lowCode: lowCode}}, {reqUrl:"/statistics/lowlevel_all_sign_renew",params:{sort:1,year:2017,level:level,index:52,area:area, lowCode: lowCode}}); } } var existArr = JSON.parse(plus.storage.getItem("levelParamsArr")); //清空数据,然后再存储新的路径 existArr.splice(0, existArr.length); existArr.push(paramsArr); plus.storage.setItem("levelParamsArr",JSON.stringify(existArr)); curLeveArr = paramsArr; current_team_index = 0; loadAllData(paramsArr); }); }; /*****************************************************************************/ /***** 数据返回处理函数 **********/ /*****************************************************************************/ var countHandle = function(res){ if(res.status == 200) { res = res.data; //折线图目标量是去年的签约量 taskNum = parseInt(res.yesterYearSign); $('#xuqianlv').waterbubble({ txt: res.renewRange, data: parseFloat(res.renewRange)/100, waterColor: '#12B7F5', lineWidth:0, radius: 75, textColor: 'rgba(0, 0, 0, 0.8)', font: 'bold 25px arial' }); $(".p-xuqianlv").html(""+res.thisYearRenew+"/"+res.yesterYearSign); $('#zhuanqianlv').waterbubble({ txt: res.switchRange, data: parseFloat(res.switchRange)/100, waterColor: '#4ECD70', lineWidth:0, radius: 75, textColor: 'rgba(0, 0, 0, 0.8)', font: 'bold 25px arial' }); $(".p-zhuanqianlv").html(""+res.thisYearSwithch+"/"+res.thisYearRenew); } else { mui.toast(res.msg); } }, dateLineHandle = function(res){ if(res.status==200){ for(var p in res.data){ taskNum = taskNum; dateData[p] = formatDateData(res.data[p].data); if(dateData[p].amountArr && dateData[p].amountArr.length>0){ $('#l-jmfx').show(); $(".l-zxt-con").hide(); mui.later(function(){ $(".l-zxt-con").show(); }, 100); $("#echarts_wushuju").hide(); } else{ $(".l-zxt-con").hide(); $("#echarts_wushuju").show(); } drawChart(dateData[p]);//初始化折线图 } } else { mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, listHandle = function(res){ if(res.status == 200) { res = res.data; var isTD = false; for(var k in res){ var list = res[k]; var topArr = soreRank(renewArr(list)); var liIndex = $(".c-lab-mor li.hit").index(); if($(".c-lab-mor li.hit a").html()=="团队"){//社区看团队数据 isTD = true; teamFenYeFun(list,topArr); }else{ var resultStr = ""; var topClass = ""; var qylResultStr = ""; var qylClass = "c-a0dc28"; // if($(".c-lab-mor li.hit a").html()=="团队"){ // qylClass = "c-17b8ec"; // } for(var j in list){ switch (topArr[j]){ case 1: topClass="cb-EA5B3A"; break; case 2: topClass="cb-FF8746"; break; case 3: topClass="cb-69CA2E"; break; default: topClass="cb-3DA9CE"; break; } resultStr+='
  • '+ '
    '+topArr[j]+'
    '+ '
    '+list[j].name+'
    '+ '
  • '; qylResultStr+='
  • '+'
    '+(parseFloat(list[j].signNum)/1000).toFixed(2)+'
    '+'
  • '; } $(".div-list"+liIndex).show(); $(".div-list"+liIndex+" .list-ul").html(resultStr); $(".div-list"+liIndex+" .div-right-data-content .list-ul").html(qylResultStr); $(".div-list"+liIndex+" li .div-name,"+".div-list"+liIndex+" li .div-amount").each(function(){ if($(this).height()==21){ $(this).addClass("mt20") }else if($(this).height()==42){ $(this).addClass("mt10") } }) if(list.length==0){ scroller1.refresh(); plus.nativeUI.closeWaiting(); return false; } //加载图表数据 var amountArrS = amountArr(list).reverse();//签约量 var nameArrs = nameArr(list).reverse();//名称 $("#chart-main"+liIndex).height(list.length*customHeight+100); $(".div-list"+liIndex+" .div-right-content").show(); var rateArrS = rateArr(list).reverse();//签约率 var renewArrS = renewArr(list).reverse();//续签量 var qylAmountArr = arr_dive_qyl(amountArrS,renewArrS);//签约量 echartsCCFun("chart-main"+liIndex,qylAmountArr,renewArrS,rateArrS,nameArrs);//区进展、社区进展的图表 } scroller1.refresh(); plus.nativeUI.closeWaiting(); } } else { mui.toast(res.msg); } }, teamFenYeFun = function(recordList,topArr){ if(recordList){ team_top_list = _.groupBy(topArr,function(item,i){return Math.floor(i/TD_PAGE_SIZE)}); team_data_list = _.groupBy(recordList,function(item,i){return Math.floor(i/TD_PAGE_SIZE)}); if(team_data_list){ loadTeamData(team_data_list[current_team_index],team_top_list[current_team_index],false); } } }, loadTeamData = function(list,topArr,isPullUp){ var resultStr = ""; var topClass = ""; var qylResultStr = ""; var qylClass = "c-a0dc28"; var liIndex = $(".c-lab-mor li.hit").index(); if(isPullUp){ var newLiIndex = $(".div-data-list").length; var chartMainId = "chart-main"+newLiIndex; var divListClassz = "div-list"+newLiIndex; var addDivList = '
    '+ '
    '+ '
      '+ '
      '+ '
      '+ '
        '+ '
        '+ '
        '+ '
        '; $(".div-data-list:last").after(addDivList); liIndex = newLiIndex; } setTimeout(function(){ var amountArrS = amountArr(list, true).reverse();//签约量 var nameArrs = nameArr(list);//名称 for(var j in list){ switch (topArr[j]){ case 1: topClass="cb-EA5B3A"; break; case 2: topClass="cb-FF8746"; break; case 3: topClass="cb-69CA2E"; break; default: topClass="cb-3DA9CE"; break; } var redClass = list[j].signNum>1500?"c-EA5B3A":""; resultStr+='
      • '+ '
        '+topArr[j]+'
        '+ '
        '+(list[j].name || "未知")+'
        '+ '
      • '; qylResultStr+='
      • '+'
        '+list[j].signNum+'
        '+'
      • '; } $(".div-list"+liIndex).show(); $(".div-list"+liIndex+" .list-ul").html(resultStr); $(".div-list"+liIndex+" .div-right-data-content .list-ul").html(qylResultStr); $(".div-list"+liIndex+" li .div-name,"+".div-list"+liIndex+" li .div-amount").each(function(){ if($(this).height()==21){ $(this).addClass("mt20") }else if($(this).height()==42){ $(this).addClass("mt10") } }) if(!list){ scroller1.refresh(); plus.nativeUI.closeWaiting(); return false; } $(".div-list"+liIndex+" .div-right-content").show(); if(!list){ $(".div-right-danwei").hide(); $("#chart-main"+liIndex).hide(); }else{ $(".div-right-danwei").show(); $("#chart-main"+liIndex).show(); var heightM = current_team_index==0?list.length*customHeight+30:list.length*customHeight; $("#chart-main"+liIndex).height(heightM); var rateArrS = rateArr(list).reverse();//签约率 var renewArrS = renewArr(list, true).reverse();//续签量 var qylAmountArr = arr_dive_qyl(amountArrS,renewArrS);//签约量 echartsTDFun("chart-main"+liIndex,qylAmountArr,renewArrS,rateArrS,nameArrs);//区进展、社区进展的图表 } scroller1.refresh(); plus.nativeUI.closeWaiting(); },200) }, drawChart = function(dateData){//初始化折线图 $(".div-switch").show(); var recordCount = 10;//一页显示几条数据 var allRecordData = dateData.amountArr.reverse(); var dateArr = dateData.dateArr.reverse(); var resultData = _.groupBy(allRecordData,function(item,i){return Math.floor(i/recordCount)}); var dateArrData = _.groupBy(dateArr,function(item,i){return Math.floor(i/recordCount)}); //以下为折线图处理 var gnum = Math.ceil(allRecordData.length / recordCount); var HandStartX,HandStartY,HandEndX,HandEndY,CountX,CountY,startPos,isScrolling,number=allRecordData.length,times=allRecordData.length%recordCount; var canvasStr = '
        '; for(var x in resultData){ canvasStr =''+canvasStr; } $(".l-zxt-inner").html(canvasStr); var dateType = $(".div-btn-group .div-btn.active").attr("data-id"); window.setTimeout(function() { for(var x in resultData){ var startDay = new Date(getDateBefore(times-1)); var resultDateArr = dateArrData[x].reverse(); var yAxis = taskNum;//maxData(resultData[x]);//求数据的最大值 $('#wcMotion'+x).wcChart({ height: 200, // width and height must be set if change yAxis:yAxis, day: startDay, points: [], dateArr:resultDateArr, dateType:dateType, data: resultData[x].reverse(), fill: {gradient: [["#17B3EC",.1], ["#17B3EC",.5]], gradientAngle: Math.PI * -45/180}, animation: null // 修复bug#3298 【医生端】总体分析排版优化。(vivo手机) }); if(x==0){ $('#wcMotion'+x).show(); } times+=recordCount; //折线图画布添加左滑和右滑效果 var wcMotion = document.getElementById('wcMotion'+x); wcMotion.addEventListener('touchstart', function(event) { HandStartX=event.touches[0].clientX; HandStartY=event.touches[0].clientY; //touches数组对象获得屏幕上所有的touch,取第一个touch var touch = event.targetTouches[0]; //取第一个touch的坐标值 startPos = {x:touch.pageX,y:touch.pageY,time:+new Date}; //这个参数判断是垂直滚动还是水平滚动 isScrolling = 0; }, false); wcMotion.addEventListener('touchend', function(event) { HandEndX=event.changedTouches[0].clientX; HandEndY=event.changedTouches[0].clientY; CountX=HandEndX-HandStartX; CountY=HandEndY-HandStartY; if((Math.abs(CountX)>Math.abs(CountY))&& Math.abs(CountX)>50){ var targetMotion = $(event.target); if(CountX<0){ if(targetMotion.next().length>0 && !targetMotion.next().hasClass("div-layer")){ targetMotion.addClass("fadeOutLeft"); targetMotion.next().removeClass("fadeOutRight").removeClass("fadeOutLeft").removeClass("fadeInLeft").addClass("fadeInRight").show(); } console.log("左滑"); }else{ if(targetMotion.prev().length>0 && !targetMotion.prev().hasClass("div-layer")){ targetMotion.addClass("fadeOutRight"); targetMotion.prev().removeClass("fadeOutRight").removeClass("fadeOutLeft").removeClass("fadeInRight").addClass("fadeInLeft").show(); } console.log("右滑"); } } }, false); wcMotion.addEventListener('touchmove', function(event) { //当屏幕有多个touch或者页面被缩放过,就不执行move操作 if(event.targetTouches.length > 1 || event.scale && event.scale !== 1) return; var touch = event.targetTouches[0]; endPos = {x:touch.pageX - startPos.x,y:touch.pageY - startPos.y}; //isScrolling为1时,表示纵向滑动,0为横向滑动 isScrolling = Math.abs(endPos.x) < Math.abs(endPos.y) ? 1:0; if(isScrolling === 0){ //阻止触摸事件的默认行为,即阻止滚屏 event.preventDefault(); } }, false); } }, 500); }, formatDateData = function(data){//折线图数据格式转化 var dateArr = []; var amountArr = []; for(var k in data){ dateArr.push(data[k].range.substring(5)); amountArr.push(data[k].amount); } return {dateArr: dateArr, amountArr: amountArr}; }, soreRank = function(arr){//排名方法 var temp = []; var lis = []; for(var i=0;i0){//去年签约量-续签量 (签约量>=续签量) resultArr.push(amountArr[k]-renewArr[k]); }else{ resultArr.push(0); } } return resultArr; }, maxData = function(data){ var maxData = Math.max.apply(Math,data); var yAxis = maxData<10?10:maxData; return yAxis; }, getStartDate = function(){ //年度开始的时间为7月1号 return chooseYear+'-07-01'; }, //获取结束时间 getEndDate = function(){ //如果是前一个年度的时间,那么结束的时间为6月30号,如果是当前年度的,则结束时间为现在 var endDate = new Date((chooseYear+1) + '-06-30'), now = new Date(); if(now < endDate){ return now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate(); }else{ return (chooseYear+1) + '-06-30'; } }, getDateBefore = function(days){//获取多少天前的日期 var now = new Date(); var date = new Date(now.getTime() - days * 24 * 3600 * 1000); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var hour = date.getHours(); var minute = date.getMinutes(); var second = date.getSeconds(); return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day); }; /*****************************************************************************/ /***** echarts图标处理 **********/ /*****************************************************************************/ var echartsFun = function(elementId,amountArrS,amountArrResult,taskArrS,rateArrS,nameArr){//区进展、社区进展的图表 var myChart = echarts.init(document.getElementById(elementId)); var height = amountArrS.length*customHeight; var option = { grid: {x:60,y: 30,height:height,borderWidth:0}, yAxis : [ { type : 'category', data : nameArr, axisLine: {show:false}, axisTick: {show:false}, splitArea: {show:false}, splitLine: {show:false}, axisLabel: {show:false} } ], xAxis : [ { type : 'value', axisLine: {show:true,lineStyle:{color:'#cccccc'}}, axisTick: {show:true,lineStyle:{color:'#cccccc'}}, axisLabel:{formatter:'{value}%',textStyle:{color:'#cccccc'}}, splitArea: {show:false}, splitLine: {show:false} }, { type : 'value', axisLine: {show:true,lineStyle:{color:'#cccccc'}}, axisTick: {show:true,lineStyle:{color:'#cccccc'}}, axisLabel:{formatter:'{value}',textStyle:{color:'#cccccc'}}, splitArea: {show:false}, splitLine: {show:false} } ], series : [ { name:'去年签约量', type:'bar', barWidth : 20,//柱图宽度 stack: '目标量', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#a0dc28', label:{show:false, position: 'insideRight'}}}, data:taskArrS, }, { name:'续签量', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#ffc149', label:{show:false, position: 'insideRight',textStyle:{color:'#fff'}}}}, data:amountArrS }, { name:'续签率', type:'line', itemStyle: {normal: {color:'red', label:{show:true,formatter:function(p){return p.value +"%";},textStyle:{color:'red'},position:'bottom'}}}, data:rateArrS, markLine:{ itemStyle:{ normal:{lineStyle:{type:'solid',color:'#925cfe'},label:{show:true,formatter:function(p){return p.value +"%";},textStyle:{color:'#925cfe'},position:'bottom'}} }, large:true, effect:{ show: false, loop: true, period: 0, scaleSize : 2, color : null, shadowColor : null, shadowBlur : null }, data:[ [ {name: '标线1起点', value: '15',xAxis:-1, xAxis: '15'}, // 当xAxis为类目轴时,数值1会被理解为类目轴的index,通过xAxis:-1|MAXNUMBER可以让线到达grid边缘 {name: '标线1终点', yAxis: nameArr[nameArr.length-1], xAxis: '15'}, // 当xAxis为类目轴时,字符串'周三'会被理解为与类目轴的文本进行匹配 ], ] } } ] }; myChart.setOption(option); }, echartsCCFun = function(elementId,qylAmountArr,renewArrS,rateArrS,nameArr){//区进展、社区进展的图表 var myChart = echarts.init(document.getElementById(elementId)); var height = nameArr.length*customHeight; var option = { grid: {x:60,y: 30,height:height,borderWidth:0}, yAxis : [ { type : 'category', data : nameArr, axisLine: {show:false}, axisTick: {show:false}, splitArea: {show:false}, splitLine: {show:false}, axisLabel: {show:false} } ], xAxis : [ { type : 'value', axisLine: {show:true,lineStyle:{color:'#cccccc'}}, axisTick: {show:true,lineStyle:{color:'#cccccc'}}, axisLabel:{formatter:'{value}%',textStyle:{color:'#cccccc'}}, splitArea: {show:false}, splitLine: {show:false} }, { type : 'value', axisLine: {show:true,lineStyle:{color:'#cccccc'}}, axisTick: {show:true,lineStyle:{color:'#cccccc'}}, axisLabel:{formatter:'{value}',textStyle:{color:'#cccccc'}}, splitArea: {show:false}, splitLine: {show:false} } ], series : [ { name:'续签量', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#ffc149', label:{show:false, position: 'insideRight',textStyle:{color:'#fff'}}}}, data:renewArrS }, { name:'去年签约量', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#A0DC28', label:{show:false, position: 'insideRight'}}}, data:qylAmountArr, }, { name:'续签率', type:'line', itemStyle: {normal: {color:'red', label:{show:true,formatter:function(p){return p.value +"%";},textStyle:{color:'red'},position:'bottom'}}}, data:rateArrS, markLine:{ itemStyle:{ normal:{lineStyle:{type:'solid',color:'#925cfe'},label:{show:true,formatter:function(p){return p.value +"%";},textStyle:{color:'#925cfe'},position:'bottom'}} }, large:true, effect:{ show: false, loop: true, period: 0, scaleSize : 2, color : null, shadowColor : null, shadowBlur : null }, data:[ [ {name: '标线1起点', value: qylAmountArr,xAxis:-1, xAxis: qylAmountArr}, // 当xAxis为类目轴时,数值1会被理解为类目轴的index,通过xAxis:-1|MAXNUMBER可以让线到达grid边缘 {name: '标线1终点', yAxis: nameArr[nameArr.length-1], xAxis: qylAmountArr}, // 当xAxis为类目轴时,字符串'周三'会被理解为与类目轴的文本进行匹配 ], ] } } ] }; myChart.setOption(option); }, echartsTDFun = function(elementId,qylAmountArr,renewArrS,rateArrS,nameArr){//团队进展图表 var myChart = echarts.init(document.getElementById(elementId)); var height = nameArr.length*customHeight; var gridY = current_team_index==0?30:0; var option = { grid: {x:60,y: gridY,height:height,borderWidth:0}, yAxis : [ { type : 'category', data : nameArr, axisLine: {show:false}, axisTick: {show:false}, splitArea: {show:false}, splitLine: {show:false}, axisLabel: {show:false} } ], xAxis : [ { type : 'value', axisLine: {show:true,lineStyle:{color:'#cccccc'}}, axisTick: {show:true,lineStyle:{color:'#cccccc'}}, axisLabel:{formatter:'{value}%',textStyle:{color:'#cccccc'}}, splitArea: {show:false}, splitLine: {show:false} }, { type : 'value', axisLine: {show:true,lineStyle:{color:'#cccccc'}}, axisTick: {show:true,lineStyle:{color:'#cccccc'}}, axisLabel:{formatter:'{value}',textStyle:{color:'#cccccc'}}, splitArea: {show:false}, splitLine: {show:false} } ], series : [ { name:'续签量', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#ffc149', label:{show:false, position: 'insideRight',textStyle:{color:'#fff'}}}}, data:renewArrS }, { name:'去年签约量', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#A0DC28', label:{show:false, position: 'insideRight'}}}, data:qylAmountArr, }, { name:'续签率', type:'line', itemStyle: {normal: {color:'red', label:{show:true,formatter:function(p){return p.value +"%";},textStyle:{color:'red'},position:'bottom'}}}, data:rateArrS, markLine:{ itemStyle:{ normal:{lineStyle:{type:'solid',color:'#925cfe'},label:{show:true,formatter:function(p){return p.value +"%";},textStyle:{color:'#925cfe'},position:'bottom'}} }, large:true, effect:{ show: false, loop: true, period: 0, scaleSize : 2, color : null, shadowColor : null, shadowBlur : null }, data:[ [ {name: '标线1起点', value: qylAmountArr,xAxis:-1, xAxis: qylAmountArr}, // 当xAxis为类目轴时,数值1会被理解为类目轴的index,通过xAxis:-1|MAXNUMBER可以让线到达grid边缘 {name: '标线1终点', yAxis: nameArr[nameArr.length-1], xAxis: qylAmountArr}, // 当xAxis为类目轴时,字符串'周三'会被理解为与类目轴的文本进行匹配 ], ] } } ] }; myChart.setOption(option); }; /*****************************************************************************/ /***** 返回事件处理 **********/ /*****************************************************************************/ mui.back = function(){ var arr = JSON.parse(plus.storage.getItem("levelParamsArr")); if(arr==null || arr.length==1){//返回到管理员首页,并刷新数据 plus.storage.removeItem("userLevel"); plus.storage.removeItem("userArea"); var mainPage =plus.webview.getWebviewById("admin.html"); mui.fire(mainPage, "refreshData"); plus.storage.removeItem("levelParamsArr"); //关闭筛选页面 var shaixuan = plus.webview.getWebviewById("xq-shaixuan.html"); if(shaixuan){ shaixuan.close(); } setTimeout(function(){ self.close(); },500) }else{ //加载当前级别数据 current_team_index = 0; arr.pop(); curLeveArr = arr[arr.length-1]; area = curLeveArr[1].params.code; level = curLeveArr[1].params.level; plus.storage.setItem("levelParamsArr",arr.length==0?plus.storage.removeItem("levelParamsArr"):JSON.stringify(arr)); loadAllData(curLeveArr); } } document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);