123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986 |
- var self;
- var type, level, area, title,sort=1,banerIndex;
- var path = {};
- var roleLevel, userRole;
- var paramsss = null;
- var startDate = getStartDate();//近3月的开始时间
- var endDate = getDateBefore(1);//近3月的结束时间
- var customHeight = 63;//自定义折线图、柱状图混合表中各项的高度
- var scroller1 = null;
- mui.plusReady(function() {
- plus.nativeUI.showWaiting();
- self = plus.webview.currentWebview();
- type = self.type;
- level = self.level;
- area = self.area;
- mui.later(function(){
- mui.fire(self, "loadData", {type: type, level: level, area: area});
- },500)
- //下拉刷新初始化
- initScroller();
- });
- function initScroller(){
- window.scroller1 = $("#wrapper1").initScroll(
- {
- pullDownAction: function(){
- $(".pullUp").hide();
- plus.nativeUI.showWaiting();
- $(".pullDown").show();
- loadAllData(curLeveArr);
- if($(".c-lab-mor #labLi2").css("display")!="none"){
- $(".c-lab-mor #labLi1").addClass("hit");
- }
- $(".c-lab-mor #labLi2").removeClass("hit");
- $(".div-list").show();
- $(".div-list2").hide();
- },pullUpAction: function() {
- $(".pullUp").hide();
- return false;
- }
- }
- );
- scroller1.on('beforeScrollStart',function() {
- console.log(scroller1.pointX);
- });
- }
- //plusReady调用完成后才可以调用plus的api
- window.addEventListener("loadData", function(e) {
- // userRole = plus!=null ?JSON.parse(plus.storage.getItem("userRole"))[0]:{} ;
- userRole = plus!=null ? JSON.parse(plus.storage.getItem("selectedRole")) : {};
- roleLevel = userRole.code == '350200' ? 4 : userRole.code.length==6 ? 3 : 2;
-
- 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,startDate, endDate);
- plus.storage.setItem("userLevel",level+"");
- plus.storage.setItem("userArea",area);
- $('#tjTitle').html(level==4? "各区进展" : level==3? "各社区进展" : "各团队进展");
- $('#sqTitle').html(level==4? "各社区进展" : level==3? "各区进展" : "各社区进展");
- if(level==4){
- title = title.substring(0,3);
- }
- $("#title").html(title);
- $(".c-lab-mor #labLi2").removeClass("hit");
- $(".c-lab-mor #labLi1").addClass("hit");
- $(".div-list").show();
- $(".div-list2").hide();
- });
-
- var old_back = mui.back;
- var curLeveArr = null;
- mui.back = function(){
- var arr = JSON.parse(plus.storage.getItem("levelArr"));
- if(arr==null || arr.length==0){
- plus.storage.removeItem("userLevel");
- plus.storage.removeItem("userArea");
- var mainPage =plus.webview.getWebviewById("admin.html");
- mui.fire(mainPage, "refreshData");
- self.close();
- }else{
- curLeveArr = arr.pop();
- plus.storage.setItem("levelArr",arr.length==0?plus.storage.removeItem("levelArr"):JSON.stringify(arr));
- $("#title").html(curLeveArr[0].title);
- loadAllData(curLeveArr);
- $(".c-lab-mor #labLi1").addClass("hit");
- $(".div-btn-group .div-btn").removeClass("active");
- $(".div-btn-group .div-btn[data-id='1']").addClass("active");
- }
- }
- $(function(){
- $(".mui-switch").find(".mui-switch-handle").css("left","-16px");
- $(".c-lab-mor li").removeClass("hit");
- $(".c-lab-mor li").eq(0).addClass("hit");
- //标签切换
- $(".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");
- if(tabid=="labLi1"){
- $(".div-list").show();
- $(".div-list2").hide();
- }else{
- $(".div-list").hide();
- $(".div-list2").show();
- $(".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")
- }
- })
- }
- 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;
- }
- }
- });
-
- $(".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 index = $(this).attr("data-index") || "";
- var dataID = $(this).attr("data-id");
- $(".lin-sel-group li").removeClass("checked");
- $(this).addClass("checked");
- $(".lin-mask").trigger("click");
- $(".p-qiu-title").html($(this).find("label").html());
- $("#Dtitle").html($(this).find("label").html()).attr("data-index",index).attr("data-id",dataID);
- //重新加载数据
- plus.nativeUI.showWaiting();
- loadAllData(curLeveArr);
- if($(".c-lab-mor #labLi2").css("display")!="none"){
- $(".c-lab-mor #labLi1").addClass("hit");
- }
- $(".c-lab-mor #labLi2").removeClass("hit");
- $(".div-list").show();
- $(".div-list2").hide();
- });
-
- });
- /*****************************************************************************/
- /***** 统计数据初始化 **********/
- /*****************************************************************************/
- function loadData(type, level, area, from, to){
- var params = {level: level, area: area, startDate: from, endDate: to}
- params.index = parseInt($("#Dtitle").attr("data-index"));
- var arr = [{endDate:endDate,area:params.area,level:params.level},
- {level: level, area: area, startDate: from, endDate: to, interval:$('.div-btn-group .div-btn.active').attr('data-id'),index:13},
- {sort:1,date:endDate,level:params.level,index:params.index,area:params.area}];
- if($(".c-lab-mor #labLi2").css("display")!="none"){
- var lowLevel = 2;
- if(level==3) lowLevel= 3;
- arr.push({sort:1,date:endDate,level:4,index:params.index,area:"350200",lowLevel:lowLevel});
- }
- curLeveArr = arr;
- loadAllData(arr);
- }
- function loadAllData(arr){
- plus.nativeUI.showWaiting();
- var interval = $('.div-btn-group .div-btn.active').attr('data-id');
- //1-1:数据截止
- // sendPost("/statistics/time",null,function(res){
- // },function(res){
- // if(res.status=="200"){
- // var date = res.data || "";//(res.data && res.data.substring(11,16)) || "";
- // $(".jiezhi-time").html(date)
- // }
- // })
- $(".jiezhi-time").html(endDate)
- //签约率、完成率
- sendPost("/statistics/sszq_qwrq_info", arr[0], null, countHandle);
-
- //1-3:左边列表
- //市管:( level:4 ) ------区所有数据
- //区管:( level:3 ) ------社区所有数据
- //社区管:( level:2 ) ----团队所有数据
- // arr[2].lowCode = lowCode;
- if($("#Dtitle").attr("data-id")=="1"){
- arr[2].index = 18;
- }else{
- arr[2].index = 19;
- }
- sendPost("/statistics/lowlevel_all", arr[2], null, listHandle);
- $("#tjTitle").html(arr[0].tagName1);
-
- if(arr.length>3 && roleLevel!=2 && roleLevel!=3){
- //1-4:右边列表
- //市管:( level:4 , lowLevel:2 ) ------社区所有数据
- //区管:( level:4 , lowLevel:3 ) ------区所有数据
- //社区管:( level:4 , lowLevel:2 ) ----社区所有数据
- // arr[3].lowCode = lowCode;
- if($("#Dtitle").attr("data-id")=="1"){
- arr[3].index = 18;
- }else{
- arr[3].index = 19;
- }
- sendPost("/statistics/lowlevel_all", arr[3], null, list2Handle);
- $(".c-lab-mor #labLi2").show();
- $("#sqTitle").html(arr[0].tagName2)
- }else{
- $(".c-lab-mor #labLi2").hide();
- }
-
- }
- function countHandle(res){
- if(res.status == 200) {
- res = res.data;
- console.log(JSON.stringify(res))
- var data,rate,countRate;
- if($("#Dtitle").attr("data-id")=="1"){//三师转签
- data = res.sszq.rate/100;
- rate = res.sszq.rate==0?'0%':res.sszq.rate.toString().substring(0,res.sszq.rate.length-2) + "%";
- countRate = res.sszq.amount+"/"+res.sszq.num;
- }else{//高危人群
- data = res.gwrq.rate/100;
- rate = res.gwrq.rate==0?'0%':res.gwrq.rate.toString().substring(0,res.gwrq.rate.length-2) + "%";
- countRate = res.gwrq.amount+"/"+res.gwrq.num;
- }
-
-
- $('#qieyuelv').waterbubble({
- // txt: res.signRate.rate.substring(0,res.signRate.rate.length-2) + "%",
- data: data,
- waterColor: '#12B7F5',
- lineWidth:0,
- radius: 75,
- textColor: 'rgba(0, 0, 0, 0.8)',
- font: 'bold 25px arial'
- });
- $(".p-baifenlv").html(rate)
- $(".p-qianyuelv").html(countRate);
-
- } else {
- mui.toast(res.msg);
- }
- }
- function listHandle(res){
- if(res.status == 200) {
- res = res.data;
- for(var k in res){
- var list = res[k];
- var resultData = soreQLY(list);
- var topArr = soreRank(rateArr(resultData));
- var resultStr = "";
- var topClass = "";
- var qylResultStr = "";
- var qylClass = "c-a0dc28";
- if(curLeveArr[1].level==2){
- qylClass = "c-17b8ec";
- }
- for(var j in resultData){
- var item = resultData[j];
- switch (j){
- case "0":
- topClass="cb-EA5B3A";
- break;
- case "1":
- topClass="cb-FF8746";
- break;
- case "2":
- topClass="cb-69CA2E";
- break;
- default:
- topClass="cb-3DA9CE";
- break;
- }
-
-
- resultStr+='<li data-name="'+item.name+'" data-code="'+item.code+'">'+
- '<div class="div-top '+topClass+'">'+topArr[j]+'</div>'+
- '<div class="div-name f-fs14">'+item.name+'</div>'+
- '</li>';
-
-
- }
- $(".div-list .list-ul").html(resultStr);
-
-
- $(".div-list li .div-name,.div-list li .div-amount").each(function(){
- if($(this).height()==21){
- $(this).addClass("mt20")
- }else if($(this).height()==42){
- $(this).addClass("mt10")
- }
- })
- //加载图表数据
- var nameArrs = nameArr(resultData).reverse();//名称
- $("#chart-main").height(list.length*customHeight+100);
- if(curLeveArr[1].level!=2){
- $(".div-list .div-right-content").show();
- $(".div-list .div-right-team-content").hide();
- var rateArrS = rateArr(resultData).reverse();//签约率
- echartsCCFun("chart-main",rateArrS,nameArrs);//区进展、社区进展的图表
-
- }
- scroller1.refresh();
- plus.nativeUI.closeWaiting();
- }
- $(".div-list .list-ul").off("click").on("click",".div-name",function(event){
- if(curLeveArr[1].level==3) return false;
- var indexParam = parseInt($("#Dtitle").attr("data-index"));
- var customArr = [];
- if($(".c-lab-mor #labLi2").css("display")=="none"){
- customArr.push({endDate:endDate,area:area,level:level,title:$("#title").html(),tagName1:$("#tjTitle").html()},
- {level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:indexParam},
- {sort:1,date:endDate,level:level,index:indexParam,area:area});
- }else{
- level = parseInt(plus.storage.getItem("userLevel"));
- area = plus.storage.getItem("userArea");
- var lowLevel = 2;if(level==3) lowLevel= 3;
- customArr.push({endDate:endDate,area:area,level:level,title:$("#title").html(),tagName1:$("#tjTitle").html(),tagName2:$("#sqTitle").html()},
- {level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:indexParam},
- {sort:1,date:endDate,level:level,index:indexParam,area:area},
- {sort:1,date:endDate,level:4,index:indexParam,area:"350200",lowLevel:lowLevel});
- }
-
- if(plus.storage.getItem("levelArr")==null){
- var arr = [];
- arr.push(customArr);
- plus.storage.setItem("levelArr",JSON.stringify(arr));
- }else{
- var existArr = JSON.parse(plus.storage.getItem("levelArr"));
- existArr.push(customArr);
- plus.storage.setItem("levelArr",JSON.stringify(existArr));
- }
-
-
- level = curLeveArr[1].level;
- level--;
- $(".c-lab-mor #labLi2").removeClass("hit").hide();
- $(".div-list2").hide();
- $(".div-list").show();
- area = $(this).closest("li").attr("data-code");
- load(type, level, area, startDate, endDate);
- var name = $(this).closest("li").attr("data-name");
- title = name;
- $("#title").html(title);
- // mui.fire(plus.webview.getWebviewById("qianyuetongji2.html"),
- // "setTitle", {title: name});
- $('#tjTitle').html(level==4? "各区进展" : level==3? "各社区进展" : "各团队进展");
- $('#sqTitle').html(level==4? "各社区进展" : level==3? "各区进展" : "各社区进展");
- path[level] = {type: type, level: level, area: area, from: startDate, to: endDate, title: name};
- event.preventDefault();
- return false;
- });
-
- } else {
- mui.toast(res.msg);
- }
- }
- function list2Handle(res){
- if(res.status == 200) {
- res = res.data;
- for(var k in res){
- var list = res[k];
- var resultData = soreQLY(list);
- var topArr = soreRank(rateArr(resultData));
- var resultStr = "";
- var qylResultStr = "";
- var topClass = "";
- for(var j in resultData){
- var item = resultData[j];
- switch (j){
- case "0":
- topClass="cb-EA5B3A";
- break;
- case "1":
- topClass="cb-FF8746";
- break;
- case "2":
- topClass="cb-69CA2E";
- break;
- default:
- topClass="cb-3DA9CE";
- break;
- }
-
-
- resultStr+='<li data-name="'+item.name+'" data-code="'+item.code+'">'+
- '<div class="div-top '+topClass+'">'+topArr[j]+'</div>'+
- '<div class="div-name f-fs14">'+item.name+'</div>'+
- '</li>';
-
-
- }
- $(".div-list2 .list-ul").html(resultStr);
-
- //加载图表数据(市管和社管看所有社区数据、区管看所有区数据)
- $(".div-list2 .div-right-content").show();
- $("#chart-main2").height(list.length*customHeight+100);
- $("#chart-main2").width($(window).width());
- var rateArrS = rateArr(resultData).reverse();//签约率
- var nameArrs = nameArr(resultData).reverse();//名称
- echartsCCFun("chart-main2",rateArrS,nameArrs);//区进展、社区进展的图表
-
- setTimeout(function(){
- scroller1.refresh();
- plus.nativeUI.closeWaiting();
- },1000)
- }
-
- //点击名称事件
- $(".div-list2 .list-ul").off("click").on("click",".div-name",function(){
- var indexParam = parseInt($("#Dtitle").attr("data-index"));
- var customArr = [];
- if($(".c-lab-mor #labLi2").css("display")=="none"){
- customArr.push({endDate:endDate,area:area,level:level,title:$("#title").html(),tagName1:$("#tjTitle").html()},
- {level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:indexParam},
- {sort:1,date:endDate,level:level,index:indexParam,area:area});
- }else{
- level = parseInt(plus.storage.getItem("userLevel"));
- area = plus.storage.getItem("userArea");
- var lowLevel = 2;if(level==3) lowLevel= 3;
- customArr.push({endDate:endDate,area:area,level:level,title:$("#title").html(),tagName1:$("#tjTitle").html(),tagName2:$("#sqTitle").html()},
- {level: level, area: area, startDate: startDate, endDate: endDate, interval:"1",index:indexParam},
- {sort:1,date:endDate,level:level,index:indexParam,area:area},
- {sort:1,date:endDate,level:4,index:indexParam,area:"350200",lowLevel:lowLevel});
- }
-
- if(plus.storage.getItem("levelArr")==null){
- var arr = [];
- arr.push(customArr);
- plus.storage.setItem("levelArr",JSON.stringify(arr));
- }else{
- var existArr = JSON.parse(plus.storage.getItem("levelArr"));
- existArr.push(customArr);
- plus.storage.setItem("levelArr",JSON.stringify(existArr));
- }
-
- level = curLeveArr[1].level;
- if(level==4) return false;
-
- if(level==3 && roleLevel==3){
- level=3;
- }
- if(roleLevel==4 || roleLevel==2){
- level = 2;
- }
-
- $(".c-lab-mor #labLi2").removeClass("hit").hide();
- $(".div-list2").hide();
- $(".div-list").show();
- area = $(this).closest("li").attr("data-code");
- load(type, level, area, startDate, endDate);
- var name = $(this).closest("li").attr("data-name");
- title = name;
- $("#title").html(title);
- // mui.fire(plus.webview.getWebviewById("qianyuetongji2.html"),
- // "setTitle", {title: name});
- $('#tjTitle').html(level==4? "各区进展" : level==3? "各社区进展" : "各团队进展");
- $('#sqTitle').html(level==4? "各社区进展" : level==3? "各区进展" : "各社区进展");
- path[level] = {type: type, level: level, area: area, from: startDate, to: endDate, title: name}
-
- });
-
- } else {
- mui.toast(res.msg);
- }
-
- }
- function load(type, level, area, from, to){
- path[level] = {type: type, level: level, area: area, from: from, to: to}
- loadData(type, level, area, from, to);
- }
- function assAmount(list){
- var all = 0;
- for(var k in list){
- all += list[k].amount;
- }
- return all;
- }
- //排名方法
- function soreRank(arr) {
- var temp = [];
- var lis = [];
- for(var i=0;i<arr.length;i++)
- lis.push(arr[i])
- lis = _.uniq(lis);
- // lis.sort();
- // lis.reverse();
- for(var i=0;i<arr.length;i++)
- temp[i] = lis.indexOf(arr[i])+1;
-
- return temp;
- }
- //签约率排序
- function soreQLY(arr) {
- var resArr = [];
- for(var i=0;i<arr.length;i++){
- var item = arr[i];
- item.rate = parseFloat(item.rate);
- resArr.push(item)
- }
- var eventData = _.chain(resArr)
- // 根据date日期字段排序
- .sortBy("rate").reverse()
- // 对集合中每一对象进行处理,返回新的集合
- .map(function (item) {
-
- return {
- amount: item.amount,
- code: item.code,
- rate: item.rate,
- name: item.name,
- num: item.num
- }
- }).value();
- console.log(JSON.stringify(eventData))
- return eventData;
-
- }
- //名称数据
- function nameArr(list){
- var nameArr = [];
- for(var k in list){
- nameArr.push(list[k].name);
- }
- return nameArr;
- }
- //签约量数据
- function amountArr(list){
- var amountArr = [];
- for(var k in list){
- amountArr.push(list[k].amount/1000);
- }
- return amountArr;
- }
- //签约率数据
- function rateArr(list){
- var rateArr = [];
- for(var k in list){
- var rate = list[k].rate?parseFloat(list[k].rate).toFixed(2):0.00;
- rateArr.push(rate);
- }
- return rateArr;
- }
- //人口数数据
- function personArr(list){
- var personArr = [];
- for(var k in list){
- personArr.push(list[k].num/1000 || 0);
- }
- return personArr;
- }
- //任务量数据
- function taskArr(list){
- var taskArr = [];
- for(var k in list){
- taskArr.push(list[k].task/1000||0);
- }
- return taskArr;
- }
- //柱状图叠层 (人口数-签约量=人口数)
- function arr_dive(personArr,amountArr){
- var resultArr = [];
- for(var k in personArr){
- resultArr.push(personArr[k]-amountArr[k]);
- }
- return resultArr;
- }
- //柱状图叠层 (签约量-目标量=超出量)
- function arr_dive_ccl(amountArr,taskArr){
- var resultArr = [];
- var chaochuValue = 0;
- for(var k in taskArr){
- chaochuValue = amountArr[k]-taskArr[k]<0?0:amountArr[k]-taskArr[k];
- resultArr.push(chaochuValue);
- }
- return resultArr;
- }
- //柱状图叠层 (签约量)
- function arr_dive_qyl(amountArr,taskArr){
- var resultArr = [];
- for(var k in taskArr){
- if(taskArr[k]-amountArr[k]>0){//目标量-签约量>0
- resultArr.push(amountArr[k]);
- }else{//目标量-签约量<0
- resultArr.push(0);
- }
- }
- return resultArr;
- }
- //柱状图叠层 (目标量)
- function arr_dive_mbl(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;
- }
- /**
- * 区进展、社区进展的图表
- * @param {Object} amountArrS
- * @param {Object} amountArrResult
- * @param {Object} taskArrS
- * @param {Object} rateArrS
- */
- function echartsCCFun(elementId,rateArrS,nameArr){
- var mblValue = $("#Dtitle").attr("data-id")=="1"?"15":"30";
- var myChart = echarts.init(document.getElementById(elementId));
- var height = rateArrS.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,//柱图宽度
- xAxisIndex:1,
- itemStyle: {normal: {barBorderRadius:0,color:'#17B3EC', label:{show:true, position: 'right',textStyle:{color:'#17B3EC'}}}},
- data:rateArrS
- }
- ]
- };
-
- myChart.setOption(option);
- }
- /**
- * 团队进展图表
- * @param {Object} amountArrS
- */
- function echartsTDFun(elementId,amountArrS,nameArr){
- var myChart = echarts.init(document.getElementById(elementId));
- var height = amountArrS.length*customHeight;
- var option = {
- calculable : true,
- grid: {x:60,y: 30,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 : [
- {
- 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:{formatter:'{value}',textStyle:{color:'#cccccc'}},
- splitArea: {show:false},
- splitLine: {show:false},
- }
- ],
- series : [
- {
- name:'签约量',
- type:'bar',
- barWidth : 20,//柱图宽度
- xAxisIndex:1,
- itemStyle: {normal: {barBorderRadius:0,color:'#17b8ec', label:{show:false, position: 'insideRight',textStyle:{color:'#fff'}}}},
- data:amountArrS
- }
- ]
- };
- myChart.setOption(option);
- }
- /**
- * 数字3位加一个逗号
- * @param {Object} n
- */
- function format_number(n){
- var b=parseInt(n).toString();
- var len=b.length;
- if(len<=3){return b;}
- var r=len%3;
- return r>0?b.slice(0,r)+","+b.slice(r,len).match(/\d{3}/g).join(","):b.slice(r,len).match(/\d{3}/g).join(",");
- }
- function clearData(type){
- $("#textTj li").removeClass("l-over");
- if(!banerIndex){
- if(type==1){
- $("#textTj li").eq(0).addClass("l-over");
- } else {
- $("#textTj li").eq(4).addClass("l-over");
- }
- }
- $('#l-jmfx').hide();
- $("#list").empty();
- $("#list2").empty();
- $(".l-data").html("0");
- }
- /*****************************************************************************/
- /***** 折线图初始化 **********/
- /*****************************************************************************/
- var dateData = {};
- function loadLineData(type, level, area, from, to, interval, index){
-
- // plus.nativeUI.showWaiting();
- var url = "/statistics/interval_total";
- var lowCode = $("#Dtitle").attr("data-lowCode") || "";
- var params = {level: level, area: area, startDate: from, endDate: to,
- interval: interval,index:index,lowCode:lowCode}
-
- sendPost(url, params, null, dateLineHandle);
- }
- /**
- * 獲取當前日期往前推三個月(當前日期減去三個月)
- * 返回日期格式:比如:2014-08-11(當前月為:2014-11-11)
- */
- function getStartDate() {
- 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;
- };
- /**
- * 获取多少天前的日期
- */
- function getDateBefore(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);
- }
- function maxData(data){
- var maxData = Math.max.apply(Math,data);
- var yAxis = maxData<10?10:maxData;
- return yAxis;
- }
- //初始化折线图
- var taskNum = 0;
- function drawChart(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 = '<div class="div-layer"></div>';
- for(var x in resultData){
- canvasStr ='<canvas id="wcMotion'+x+'" class="canvas-wc animated" style="display:block"></canvas>'+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);
-
- }
- function dateLineHandle(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);
- // $('#l-legend').hide();
- $("#echarts_wushuju").hide();
- $('#l-times').html(type==1? '(人)' : '(次)').hide();
- } else{
- $(".l-zxt-con").hide();
- $("#echarts_wushuju").show();
- // $('#l-legend').hide();
- }
- drawChart(dateData[p]);//初始化折线图
- }
- } else {
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }
- //折线图数据格式转化
- function formatDateData(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};
- }
- window.addEventListener("toBack", function(e) {
- mui.back();
- });
- //弹出遮罩
- $(".icon-remark").on("click", function(e) {
- $(".modal-overlay").addClass("modal-overlay-visible");
- setTimeout(function(){
- $(".modal-content").show();
- },50)
- });
- $(".div-close").on("click",function(){
- $(".modal-overlay").removeClass("modal-overlay-visible");
- $(".modal-content").hide();
- })
- document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
|