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 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 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();//近3月的开始时间 // endDate = getDateBefore(0);//近3月的结束时间 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(chooseYear+"年(按任务)"); //搜集页面请求的参数 var paramsArr = [],resultArr = []; var index = 13; var lowCode = $("#Dtitle").attr("data-lowCode") || ""; if(lowCode){ index = 17; } if(level==4){//市管 paramsArr.push({tags:["各区","社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/sign_info",params:{endDate:endDate,area:area,level:level,lowCode:lowCode, year: chooseYear}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:index,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:level,index:index,area:area,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:level,index:index,area:area,lowLevel:2,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:level,index:index,area:area,lowLevel:1,lowCode:lowCode}}); }else if(level==3){//区管 paramsArr.push({tags:["社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/sign_info",params:{endDate:endDate,area:area,level:level,lowCode:lowCode, year: chooseYear}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:index,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:level,index:index,area:area,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:level,index:index,area:area,lowLevel:1,lowCode:lowCode}}); }else if(level==2){//社区管 paramsArr.push({tags:["团队"],curTitle:title,level:level}, {reqUrl:"/statistics/sign_info",params:{endDate:endDate,area:area,level:level,lowCode:lowCode, year: chooseYear}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:index,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:level,index:index,area:area,lowCode:lowCode}}); } resultArr.push(paramsArr); plus.storage.setItem("levelParamsArr",JSON.stringify(resultArr)); 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 = 13; var lowCode = $("#Dtitle").attr("data-lowCode") || ""; if(lowCode){ index = 17; } //1-4 :加载签约率、完成率 arr[1].params.index = index; arr[1].params.lowCode = lowCode; arr[1].params.year = chooseYear; arr[1].params.endDate = endDate; sendPost(arr[1].reqUrl, arr[1].params, null, countHandle); //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; arr[2].params.lowCode = lowCode; arr[2].params.startDate = startDate; arr[2].params.endDate = endDate; sendPost(arr[2].reqUrl, arr[2].params, null, dateLineHandle); //1-6:加载【第一个】tab标签数据 arr[3].params.index = index; arr[3].params.lowCode = lowCode; arr[3].params.date = endDate; 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; } } ); // scroller1.on('beforeScrollStart',function() { // console.log(scroller1.pointX); // }); }, /** * 初始化筛选事件 */ shaixuanInit = function(main){ var shaixuan = plus.webview.getWebviewById('shaixuan2.html'); if(!shaixuan){ shaixuan = mui.createWindow({ id: 'shaixuan2.html', url: 'shaixuan2.html', styles: { top: 0, bottom: 0, left: '20%', width: '80%', scorllIndicator: "none" }, show:{ aniShow: "slide-in-right", duration: "400" }, extras:{ showType: 1 } }); } 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"); //1-6:加载tab标签数据 if($(this).attr("data-click")=="false"){//tab数据未加载 plus.nativeUI.showWaiting(); var index = 13; var lowCode = $("#Dtitle").attr("data-lowCode") || ""; if(lowCode){ index = 17; } if(liIndex==1){//社区数据 curLeveArr[4].params.index = index; curLeveArr[4].params.lowCode = lowCode; curLeveArr[4].params.date = endDate; sendPost(curLeveArr[4].reqUrl, curLeveArr[4].params, null, listHandle); }else if(liIndex==2){//团队数据 curLeveArr[5].params.index = index; curLeveArr[5].params.lowCode = lowCode; curLeveArr[5].params.date = endDate; sendPost(curLeveArr[5].reqUrl, curLeveArr[5].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; 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 = 13; var lowCode = $("#Dtitle").attr("data-lowCode") || ""; if(lowCode){ index = 17; } if(level==3 && $(".c-lab-mor li.hit a").html()=="各区"){//区管 paramsArr.push({tags:["社区","团队"],curTitle:title,level:level}, {reqUrl:"/statistics/sign_info",params:{endDate:endDate,area:area,level:level,lowCode:lowCode, year: chooseYear}}, {reqUrl:"/statistics/interval_total",params:{level: level, area: area, startDate: startDate, endDate: endDate, interval:$('.div-btn-group .div-btn.active').attr('data-id'),index:index,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:level,index:index,area:area,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:level,index:index,area:area,lowLevel:1,lowCode:lowCode}}); }else{//社区管 paramsArr.push({tags:["团队"],curTitle:title,level:2}, {reqUrl:"/statistics/sign_info",params:{endDate:endDate,area:area,level:2,lowCode:lowCode, year: chooseYear}}, {reqUrl:"/statistics/interval_total",params:{level: 2, area: area, startDate: startDate, endDate: endDate, interval:$('.div-btn-group .div-btn.active').attr('data-id'),index:index,lowCode:lowCode}}, {reqUrl:"/statistics/lowlevel_all",params:{sort:1,date:endDate,level:2,index:index,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; }); /* $(".demo-comtop").on("click","h1",function(){ $(".lin-mask").show(); $(".lin-sel-group").show(); }); $(".lin-mask").on("click",function(){ $(".lin-mask").hide(); $(".lin-sel-group").hide(); }); $(".lin-sel-group").on("click","li",function(){ var lowCode = $(this).attr("data-lowCode") || ""; var dataID = $(this).attr("data-id"); if(dataID=="2"){//整体签约(按人口) $(".span-amount1").html("人口数"); $(".span-amount2").html("目标量").show(); $(".span-amount-color").show(); }else{ $(".span-amount1").html("目标量"); $(".span-amount2").html("超出量").hide(); $(".color-block.span-amount-color").css("display","none"); } $(".lin-sel-group li").removeClass("checked"); $(this).addClass("checked"); $(".lin-mask").trigger("click"); $("#Dtitle").attr("data-lowCode",lowCode).attr("data-id",dataID); //重新加载数据 current_team_index = 0; plus.nativeUI.showWaiting(); loadAllData(curLeveArr); }); */ //弹出遮罩 $(".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){ var lowCode = e.detail.lowCode || ""; var dataID = e.detail.id; var year = e.detail.year; var name = e.detail.name; chooseYear = year; if(dataID=="2"){//整体签约(按人口) $(".span-amount1").html("人口数"); $(".span-amount2").html("目标量").show(); $(".span-amount-color").show(); }else{ $(".span-amount1").html("目标量"); $(".span-amount2").html("超出量").hide(); $(".color-block.span-amount-color").css("display","none"); } $(".choose-label").text(year+"年("+name+")"); $("#Dtitle").attr("data-lowCode",lowCode).attr("data-id",dataID); //重新加载数据 current_team_index = 0; plus.nativeUI.showWaiting(); startDate = getStartDate(); endDate = getEndDate(); //更新选择的时间 curLeveArr[1].params.year = year; curLeveArr[1].params.endDate = endDate; curLeveArr[2].params.startDate = startDate; curLeveArr[2].params.endDate = endDate; if(curLeveArr[3]){ curLeveArr[3].params.date = endDate; } if(curLeveArr[4]){ curLeveArr[4].params.date = endDate; } if(curLeveArr[5]){ curLeveArr[5].params.date = endDate; } //更新选择的lowCode curLeveArr[1].params.lowCode = lowCode; curLeveArr[2].params.lowCode = lowCode; if(curLeveArr[3]){ curLeveArr[3].params.lowCode = lowCode; } if(curLeveArr[4]){ curLeveArr[4].params.lowCode = lowCode; } if(curLeveArr[5]){ curLeveArr[5].params.lowCode = lowCode; } //更新dataId // curLeveArr[2].params.interval = dataId; // $('.div-btn-group .div-btn').attr("data-id",dataId); loadAllData(curLeveArr); }); //说明信息相关事件 $("#closeBtn").on("tap", function(){ $(".information").hide(); scroller1.refresh(); }); $(".info-icon").on("tap", function(){ $(".information").show(); scroller1.refresh(); }); }; /*****************************************************************************/ /***** 数据返回处理函数 **********/ /*****************************************************************************/ var countHandle = function(res){ if(res.status == 200) { res = res.data; console.log(JSON.stringify(res)) $('#qieyuelv').waterbubble({ txt: res.signRate.rate.substring(0,res.signRate.rate.length-2) + "%", data: res.signRate.rate/100, waterColor: '#12B7F5', lineWidth:0, radius: 75, textColor: 'rgba(0, 0, 0, 0.8)', font: 'bold 25px arial' }); $(".p-qianyuelv").html(""+res.signRate.sign+"/"+res.signRate.people); $('#dabiaolv').waterbubble({ txt: res.signTaskRate.rate.substring(0,res.signTaskRate.rate.length-2) + "%", data: res.signTaskRate.rate/100, waterColor: '#4ECD70', lineWidth:0, radius: 75, textColor: 'rgba(0, 0, 0, 0.8)', font: 'bold 25px arial' }); $(".p-dachenglv").html(""+res.signTaskRate.sign+"/"+res.signTaskRate.people); } else { mui.toast(res.msg); } }, dateLineHandle = function(res){ if(res.status==200){ for(var p in res.data){ taskNum = res.data[p].taskNum; dateData[p] = formatDateData(res.data[p].data); if(dateData[p].amountArr && dateData[p].amountArr.length>0){ $('#l-jmfx').toggle(p == "index_13" ); $(".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; for(var k in res){ var list = res[k]; var topArr = soreRank(amountArr(list)); var liIndex = $(".c-lab-mor li.hit").index(); if($(".c-lab-mor li.hit a").html()=="团队"){//社区看团队数据 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].amount)/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(); $(".div-list"+liIndex+" .div-right-team-content").hide(); var rateArrS = rateArr(list).reverse();//签约率 var personArrS = personArr(list).reverse();//人口数 var taskArrS = taskArr(list).reverse();//任务量 var amountArrResult = arr_dive(personArrS,amountArrS); var mblValue = parseFloat(list[0].signTaskNum).toFixed(2); //目标率 if($("#Dtitle").attr("data-id")=="2"){//整体签约(按人口) $(".div-rks-title").html("人口数"); $(".div-mbl-title").html("目标量"); echartsFun("chart-main"+liIndex,amountArrS,amountArrResult,taskArrS,rateArrS,nameArrs,mblValue);//区进展、社区进展的图表 }else{ $(".div-rks-title").html("目标量"); $(".div-mbl-title").html("超出量"); var qylAmountArr = arr_dive_qyl(amountArrS,taskArrS);//签约量 var mblAmountArr = arr_dive_mbl(amountArrS,taskArrS);//目标量 var cclAmountArr = arr_dive_ccl(amountArrS,taskArrS);//超出量(目标量-签约量) echartsCCFun("chart-main"+liIndex,qylAmountArr,mblAmountArr,cclAmountArr,rateArrS,nameArrs,mblValue); } } 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-17b8ec"; 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);//签约量 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].amount>1500?"c-EA5B3A":""; resultStr+='
      • '+ '
        '+topArr[j]+'
        '+ '
        '+(list[j].name || "未知")+'
        '+ '
      • '; qylResultStr+='
      • '+'
        '+list[j].amount+'
        '+'
      • '; } $(".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").hide(); if(!list){ $(".div-right-danwei").hide(); $(".div-list"+liIndex+" .div-right-team-content").hide(); $("#chart-main"+liIndex).hide(); }else{ if(chooseYear == 2016){ $(".tk-span").hide(); } $(".div-right-danwei").show(); $(".div-list"+liIndex+" .div-right-team-content").show(); $("#chart-main"+liIndex).show(); var heightM = current_team_index==0?list.length*customHeight+30:list.length*customHeight; $("#chart-main"+liIndex).height(heightM); //增加调控量的数据显示 var regulationAmount = list[0].signRegulationNum; echartsTDFun("chart-main"+liIndex,amountArrS.reverse(),nameArrs.reverse(), regulationAmount);//团队进展图表 } 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){//目标量-签约量>0 resultArr.push(amountArr[k]); }else{//目标量-签约量<0 resultArr.push(0); } } return resultArr; }, arr_dive_mbl = function(amountArr,taskArr){//柱状图叠层 (目标量) var resultArr = []; for(var k in taskArr){ if(taskArr[k]-amountArr[k]>0){//目标量-签约量>0 resultArr.push(taskArr[k]-amountArr[k]); }else{//目标量-签约量<0 resultArr.push(taskArr[k]); } } return resultArr; }, maxData = function(data){ var maxData = Math.max.apply(Math,data); var yAxis = maxData<10?10:maxData; return yAxis; }, getStartDate = function(){//獲取當前日期往前推三個月(當前日期減去三個月),返回日期格式:比如:2014-08-11(當前月為:2014-11-11) /* 按年度来计算的时候,开始时间是该年度7月1号还是到下一个年的6月30号结束 var newDate = new Date(); var startY = newDate.getFullYear(); var startM = newDate.getMonth() - 3; var startD = newDate.getDate(); // 日期賦值 var mydate = new Date(startY, startM, startD); var strYear = mydate.getFullYear(); //顯示的月份要加一,因為月份是從0開始的 var strMonth = mydate.getMonth() + 1; var strDate = mydate.getDate(); if (strMonth.toString().length == 1) strMonth = "0" + strMonth; if (strDate.toString().length == 1) strDate = "0" + strDate; var strStartDate = strYear + "-" + strMonth + "-" + strDate; return strStartDate; */ return chooseYear+'-07-01'; }, //获取结束时间 getEndDate = function(){ var nowdate = new Date(); var year = nowdate.getFullYear(); var month = nowdate.getMonth() + 1; var day = nowdate.getDate(); var endDate = new Date((parseInt(chooseYear)+1) + '-06-30'); var now = new Date(); // var endDate = new Date((chooseYear+1) + '-06-30'), // now = new Date(); if(now <= endDate){ return now.getFullYear()+"-"+((now.getMonth()+1)>=10?(now.getMonth()+1):("0"+(now.getMonth()+1)))+"-"+(now.getDate()>=10?now.getDate():("0"+now.getDate())); }else{ return (parseInt(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,mblValue){//区进展、社区进展的图表 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:'#17b3ec', label:{show:false, position: 'insideRight'}}}, data:taskArrS, }, { name:'签约量', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#a0dc28', label:{show:false, position: 'insideRight',textStyle:{color:'#fff'}}}}, data:amountArrS }, { name:'人口数', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#ffc149', label:{show:false, position: 'insideRight'}}}, data:amountArrResult }, { 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: mblValue,xAxis:-1, xAxis: mblValue}, // 当xAxis为类目轴时,数值1会被理解为类目轴的index,通过xAxis:-1|MAXNUMBER可以让线到达grid边缘 {name: '标线1终点', yAxis: nameArr[nameArr.length-1], xAxis: mblValue}, // 当xAxis为类目轴时,字符串'周三'会被理解为与类目轴的文本进行匹配 ], ] } } ] }; myChart.setOption(option); }, echartsCCFun = function(elementId,qylAmountArr,mblAmountArr,cclAmountArr,rateArrS,nameArr,mblValue){//区进展、社区进展的图表 // var mblValue = $("#Dtitle").attr("data-id")=="1"?"15":"30"; var myChart = echarts.init(document.getElementById(elementId)); var height = qylAmountArr.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:qylAmountArr, }, { name:'目标量', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#ffc149', label:{show:false, position: 'insideRight',textStyle:{color:'#fff'}}}}, data:mblAmountArr }, { name:'超出量', type:'bar', barWidth : 20,//柱图宽度 stack: '人数', xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#A0DC28', label:{show:false, position: 'insideRight'}}}, data:cclAmountArr }, { 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: mblValue,xAxis:-1, xAxis: mblValue}, // 当xAxis为类目轴时,数值1会被理解为类目轴的index,通过xAxis:-1|MAXNUMBER可以让线到达grid边缘 {name: '标线1终点', yAxis: nameArr[nameArr.length-1], xAxis: mblValue}, // 当xAxis为类目轴时,字符串'周三'会被理解为与类目轴的文本进行匹配 ], ] } } ] }; myChart.setOption(option); }, echartsTDFun = function(elementId,amountArrS,nameArr, regulationAmount){//团队进展图表 var myChart = echarts.init(document.getElementById(elementId)); var height = amountArrS.length*customHeight; var xAxis = null; if(current_team_index==0){ xAxis = [ { type : 'value', axisLine: {show:false}, axisTick: {show:false}, axisLabel: {show:false}, splitArea: {show:false}, splitLine: {show:false} }, { type : 'value', axisLine: {show:true,lineStyle:{color:'#cccccc'}}, axisTick: {show:true,lineStyle:{color:'#cccccc'}}, axisLabel:{show:true,formatter:'{value}',textStyle:{color:'#cccccc'}}, splitArea: {show:false}, splitLine: {show:false}, } ]; }else{ xAxis = [ { type : 'value', max:team_data_list[0][0].amount, axisLine: {show:false}, axisTick: {show:false}, axisLabel: {show:false}, splitArea: {show:false}, splitLine: {show:false} }, { type : 'value', max:team_data_list[0][0].amount, axisLine: {show:false,lineStyle:{color:'#cccccc'}}, axisTick: {show:false,lineStyle:{color:'#cccccc'}}, axisLabel:{show:false,formatter:'{value}',textStyle:{color:'#cccccc'}}, splitArea: {show:false}, splitLine: {show:false}, } ]; } var gridY = current_team_index==0?30:0; //调控量的配置信息 var 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: regulationAmount,xAxis:-1, xAxis: regulationAmount}, // 当xAxis为类目轴时,数值1会被理解为类目轴的index,通过xAxis:-1|MAXNUMBER可以让线到达grid边缘 {name: '标线1终点', yAxis: nameArr[nameArr.length-1], xAxis: regulationAmount}, // 当xAxis为类目轴时,字符串'周三'会被理解为与类目轴的文本进行匹配 ], ] } if(chooseYear == 2016){ markLine.data = []; $(".tk-span").hide(); } var option = { calculable : true, grid: {x:60,y: gridY,height:height,borderWidth:0}, yAxis : [ { type : 'category', // boundaryGap : false, data : nameArr, axisLine: {show:false}, axisTick: {show:false}, splitArea: {show:false}, splitLine: {show:false}, axisLabel: {show:false} } ], xAxis : xAxis, series : [ { name:'签约量', type:'bar', barWidth : 20,//柱图宽度 xAxisIndex:1, itemStyle: {normal: {barBorderRadius:0,color:'#17b8ec', label:{show:false, position: 'insideRight',textStyle:{color:'#fff'}}}}, data:amountArrS, markLine: markLine } ] }; myChart.setOption(option); }; /*****************************************************************************/ /***** 返回事件处理 **********/ /*****************************************************************************/ mui.back = function(){ console.log("back"); 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("shaixuan2.html"); if(shaixuan){ shaixuan.close(); } setTimeout(function(){ self.close(); },500) }else{ //加载当前级别数据 current_team_index = 0; arr.pop(); curLeveArr = arr[arr.length-1]; plus.storage.setItem("levelParamsArr",arr.length==0?plus.storage.removeItem("levelParamsArr"):JSON.stringify(arr)); loadAllData(curLeveArr); } } document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);