var self; var type, level, area, title,sort=1; var path = {}; var roleLevel, userRole; //初始化计算选择的年份 var chooseYear; var now = new Date(); if(now.getMonth() >= 6){ chooseYear = now.getFullYear(); }else{ chooseYear = now.getFullYear() - 1; } //绑定按钮事件 bindEvents(); //初始化事件 mui.plusReady(function() { self = plus.webview.currentWebview(); type = self.type; level = self.level; area = self.area; //初始显示选中的年份 $(".choose-label").text(chooseYear+"年"); mui.later(function(){ mui.fire(self, "loadData", {type: type, level: level, area: area}); },500) //下拉刷新初始化 initScroller(); shaixuanInit(self); }); function initScroller(){ scroller1 = $("#wrapper1").initScroll( { pullDownAction: function(){ $(".pullUp").hide(); plus.nativeUI.showWaiting(); type = type; level = level; area = area; mui.later(function(){ mui.fire(self, "loadData", {type: type, level: level, area: area,title:title}); },500) $(".c-lab-mor #labLi1").addClass("hit"); $(".c-lab-mor #labLi2").removeClass("hit"); $(".div-list").show(); $(".div-list2").hide(); },pullUpAction: function() { $(".pullUp").hide(); return false; } } ); } //返回事件 mui.back = function(){ if(level==4 || level==roleLevel){ var mainPage =plus.webview.getWebviewById("admin.html"); mui.fire(mainPage, "refreshData"); //关闭筛选页面 var shaixuan = plus.webview.getWebviewById("shaixuan2.html"); if(shaixuan){ shaixuan.close(); } self.close(); } else{ level++; var params = path[level]; if(!params){ level++; params = path[level]; } type = params.type; area = params.area; load(type, level, area); title = params.title || userRole.name; if(level==4){ title = title.substring(0,3); } $("#title").html(title); $('#tjTitle').html("各科室管理"); $(".c-lab-mor #labLi1").addClass("hit") } } /** * 初始化筛选事件 */ function shaixuanInit(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" } }); } window.addEventListener("hideShaiXuan",function(){ 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); }); } function bindEvents(){ //标签切换 $(".c-lab-mor li").click(function(){ var tabid = $(this).attr("id"); var top = $(this).offset().top; $(".c-lab-mor li").removeClass("hit"); $(this).addClass("hit"); $("#list div.l-list").hide(); $("#list2 div.l-list").hide(); if(tabid=="labLi1"){ $("#list").show(); $("#list2").hide(); $("#div_list").show(); }else{ $("#list").hide(); $("#list2").show(); $("#div_list2").show(); } 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; } } }); //左滑筛选区域的数据 $('.header-link').on("tap", function(){ var self = plus.webview.currentWebview(); mui.fire(self, "showShaiXuan"); }); window.addEventListener("refresh", function(e){ chooseYear = e.detail.year; $(".choose-label").text(chooseYear+"年"); loadData(type, level, area); loadLineData(type, level, area); }); //说明信息相关事件 $("#closeBtn").on("tap", function(){ $(".information").hide(); scroller1.refresh(); }); $(".info-icon").on("tap", function(){ $(".information").show(); scroller1.refresh(); }); } /*****************************************************************************/ /***** 统计数据初始化 **********/ /*****************************************************************************/ //加载数据 function loadData(type, level, area){ clearData(type); var params = {level: level, area: area, year: chooseYear} loadAmount(params); if(level==3){//市级管理员才可以查看市下面的所有社区数据 $(".c-lab-mor #labLi2").removeClass("c-hide"); } } //后台接收数据 function loadAmount(params){ 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) } }) console.log("第一个:"+JSON.stringify(params)) sendPost("/statistics/Consulting_Title", params, null, countHandle); params.sort = 1;//排序(0:升序 1:降序) params.date = params.endDate; params.date = getEndDate(); console.log("第二个:"+JSON.stringify(params)) // params.lowlevel = "3"; sendPost("/statistics/Consulting_StatList", params, null, listHandle); // delete params.lowLevel; if($(".c-lab-mor #labLi2").css("display")!="none"){ if(roleLevel==3){//市级管理员才可以查看市下面的所有社区数据 params.lowlevel = "1"; console.log("第三个:"+JSON.stringify(params)) sendPost("/statistics/Consulting_StatList", params, null, list2Handle); delete params.lowLevel; } } } //格式化数量 function assNoRelyCount(list){ var all = 0; for(var k in list){ all += list[k].noRelyCount; } return all; } //排序 function soreRank(arr) { var temp = []; var lis = []; for(var i=0;i'); $('#div_list').remove(); if($div){ $div.append(template("list_tmpl", res)); if(level>2){ $("li", $div).on("tap", function(){ level--; area = $(this).attr("data-code"); load(type, level, area); var name = $(this).attr("data-name"); title = name; $("#title").html(title); $('#tjTitle').html("各医生情况"); path[level] = {type: type, level: level, area: area, title: name} }) } $("#list").append($div); scroller1.refresh(); plus.nativeUI.closeWaiting(); } } else { mui.toast(res.msg); } } function list2Handle(res){ if(res.status == 200) { template.helper("setRate", function(all, noRelyCount){ if(all == 0) return 0; return (noRelyCount / all * 100).toFixed(2); }); res = res.data; var $div; var list = res.resultList; var topArr = soreRank(amountArr(list)); for(var j in list){ list[j].top = topArr[j]; } res.all = assNoRelyCount(list); res.list = list; res.level = level; $div = $('
'); $('#div_list2').remove(); if($div){ $div.append(template("list_tmpl", res)); // $("li", $div).on("tap", function(){ // level = 2; // area = $(this).attr("data-code"); // load(type, level, area); // var name = $(this).attr("data-name"); // title = name; // $("#title").html(title); // $('#tjTitle').html("各医生情况"); // path[level] = {type: type, level: level, area: area, title: name} // }) $("#list2").append($div); scroller1.refresh(); plus.nativeUI.closeWaiting(); } } else { mui.toast(res.msg); } } function countHandle(res){ if(res.status == 200) { res = res.data.result[0] || []; $('#div_total').html(res.total); $('#div_noRelyRate').html(res.noRelyRate); $('#div_noRelyCount').html(res.noRelyCount); $('#div_relyRate').html(res.relyRate); } else { mui.toast(res.msg); } } function clearData(type){ $("#textTj li").removeClass("l-over"); $('#l-jmfx').show(); $("#list").empty(); $("#list2").empty(); $(".l-data").html("0"); } //获取结束时间 function getEndDate(){ chooseYear = parseInt(chooseYear); var endDate = new Date((chooseYear+1) + '-06-30'), now = new Date(); if(now <= endDate){ var month = now.getMonth()+1, date1 = now.getDate(); if(month < 10){ month = "0"+month; } if(date1 < 10){ date1 = "0"+date1; } return now.getFullYear()+"-"+month+"-"+date1; }else{ return (chooseYear+1) + '-06-30'; } } /*****************************************************************************/ /***** 柱状图初始化 **********/ /*****************************************************************************/ function loadLineData(type, level, area){ plus.nativeUI.showWaiting(); var url = "/statistics/getCoutListByTime"; var params = {level: level, area: area, year: chooseYear} sendPost(url, params, null, dateLineHandle); } //初始化柱状图 function drawChart(nameData,numData){ nameData.push("时间段"); var myChart = echarts.init(document.getElementById("l-zxt-con")); var option = { calculable : true, grid: {y: 25, y2:30, x:0, x2:20,width:$(".l-zxt-con").width(),borderColor:'#ffffff'}, xAxis : [ { type : 'category', axisLine: {show:true,lineStyle:{color:'#dcdcdc',width:1}}, axisTick: {show:false}, axisLabel: {show:true,lineStyle:{color:'#323232'}}, splitArea: {show:false}, splitLine: {show:false}, data : nameData } ], yAxis : [ { type : 'value', axisLine: {show:true,lineStyle:{color:'#dcdcdc',width:1}}, axisTick: {show:false}, axisLabel: {show:false}, splitArea: {show:false}, splitLine: {show:false}, axisLabel:{show:false} } ], series : [ { name:'首次回复时间分布', type:'bar', barWidth:20, itemStyle: {normal: {color:'#17B3EC', label:{show:true},barBorderRadius:0}}, data:numData } ] }; myChart.setOption(option); } function dateLineHandle(res){ if(res.status==200){ var resData = res.data.resultList; var nameData = [],numData = []; for(var p in resData){ nameData.push(resData[p].name); numData.push(resData[p].num); } drawChart(nameData,numData); } else { mui.toast(res.msg); } plus.nativeUI.closeWaiting(); } function load(type, level, area, from, to){ $('#labLi2').toggle(level == 3); if($(".c-lab-mor .hit").attr("id")=="labLi2"){ $('#list2').toggle(level == 3); $('#labLi2').removeClass("hit"); } $('#list').show(); $("#list2").hide(); path[level] = {type: type, level: level, area: area} loadData(type, level, area); loadLineData(type, level, area); } window.addEventListener("loadData", function(e) { // userRole = JSON.parse(plus.storage.getItem("userRole"))[0] ; userRole = JSON.parse(plus.storage.getItem("selectedRole")); // roleLevel = userRole.code == '350200' ? 4 : userRole.code.length==6 ? 3 : 2; roleLevel=3; type = e.detail.type; $('.type-'+ type).show(); level = e.detail.level || roleLevel; area = e.detail.area || userRole.code; title = e.detail.title || userRole.name; load(type, level, area); $('#tjTitle').html("各科室管理"); if(!e.detail.title){ $('#labLi2').toggle(level == 3); } $(".c-lab-mor #labLi2").removeClass("hit"); if(level==4){ title = title.substring(0,3); } $("#title").html(title); }); window.addEventListener("toBack", function(e) { mui.back(); }); document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);