var reqList = [],reqLists = [[],[],[]]; //记录请求的参数和url,用于后退时使用 var colors={"0":"#73acff","1":"#fdd56a","2":"#fdb36a", "3":"#fd866a","4":"#9e87ff","5":"#58d5ff", "6":"#20d7ad","7":"#fd866a","8":"#fdb36a","9":"#fdd56a","10":"#264478","11":"#43682b","12":"#5b9db5"} Vue.use(Vuedals.default); new Vue({ el: "#main", data: { isloading:false, //加载中 pageData2:{}, pageData:{}, tabledata0:[], tabledata1:[], tabledata2:[], hastopbar0:true, slaveKey1:"", reqListLength0:1, reqListLength1:1, reqListLength2:1, data0:[], data1:[], data2:[], pieShow0:true, pieShow1:true, pieShow2:true, selDateType:undefined, // 1-日,2-周, 3-月 index:150, pageIndex:1, rhfs:"", informationList:[{},{code:"1",title:"上门服务",name:"smfu",tip:"统计当前年度至今上门服务情况,点击右上角可切换时间范围查询",lineChartTitle:"新增服务工单趋势",lineChartIndex:"",lineChartName:"服务工单"}, {code:"2",title:"入户访视",name:"rhfs",tip:"统计当前年度至今入户访视情况,点击右上角可切换时间范围查询",lineChartTitle:"访视量新增趋势",lineChartIndex:"",lineChartName:"访视量"}], informationShow:true, information:{}, ltabList:[{},{indexNames:{"serviceOrderTrend": "服务工单"},xDatas:{},yDatas:{},names:[]}, {indexNames:{"serviceOrderTrend": "访视量"},xDatas:{},yDatas:{},names:[]},], //请求页面所需参数 levelList:[{level:"4",areaLevel:"2"},{level:"3",areaLevel:"3"},{level:"2",areaLevel:"4"}], //两种搜索,地区等级对比 areaLevel:"", // 2、市,3、区,4、社区,5、团队\ initareaLevel:"", initlevel: '', initarea: '', level: '', area: '', areaTitle: '', initareaTitle: '', lowLevel:3, initlowLevel:3, selectedDateType: 1, //折线图坐标值1-日,2-周,3-月 lowCode: '', chooseYear: '', start: "", end: "", userRole: '', tabnumber:3, reqListLength:1, appname:"上门服务", }, components: { vuedals: Vuedals.Component }, watch:{ areaTitle:function(val){ //更新区域名称 EventBus.$emit('update-area-name', { 'areaName': val }); }, chooseYear:function(val){ //更新年份 EventBus.$emit('update-statistics-year', { 'selectDate': val }); }, }, mounted: function () { var vm=this //初始化数据 initData(vm); vm.bindEvent() }, methods: { getData:function(isNext,index ){ //是否下转 var vm = this var params={ areaTitle:vm.areaTitle, areaLevel: vm.areaLevel, level: vm.level, area: vm.area, endDate: vm.end, startDate: vm.start, lowLevel: vm.lowLevel, index:index } // if(index!=undefined){ // loadData([index], vm); //刷新数据 // }else if(vm.pageIndex == 1){ loadData([1,3,4,5], vm); //刷新数据 }else{ loadData([2,6,7,8], vm); //刷新数据 } if(isNext){ //存储请求所带的参数 reqList.push(params); if(index!=undefined){ reqLists[index].push(params) vm["reqListLength"+index] = reqLists[index].length+1 } } }, //表格tab切换/下转 getnewdata:function(arg,index){ var vm = this if(arg.level){ vm.level = arg.level vm.areaLevel = _.find(vm.levelList,{level:vm.level}).areaLevel } if(arg.area){ vm.area = arg.area } if(arg.areaTitle){ vm.areaTitle = arg.areaTitle } if(arg.lowLevel){ vm.lowLevel=arg.lowLevel }else{ if(vm.areaLevel){ vm.lowLevel=arg.area == '350200' ? 3 : vm.area.length == 6 ? 4 : 5; }else{ vm.lowLevel = arg.lowLevel || "" } } vm.getData(arg.level,index) //有传level,说明是下转 }, getnewdata0:function(arg){ var vm = this if(vm.hastopbar0){ //服务项时 vm.hastopbar0 = false vm.slaveKey1 = arg.area vm.area=vm.initarea vm.areaLevel=vm.initareaLevel vm.level=vm.initlevel vm.lowLevel = vm.initlowLevel vm.getData(true,0) }else{ vm.getnewdata(arg,0) } }, getnewdata1:function(arg){ var vm = this vm.getnewdata(arg,1) }, getnewdata2:function(arg){ var vm = this vm.getnewdata(arg,2) }, backClickHandel:function(index,lIndex,refIndex){ var vm=this var hasIndex = _.findLastIndex(reqList,{index:index}) reqList.splice(hasIndex,1); var preInfo = reqLists[lIndex].pop(); var info = reqLists[lIndex][reqLists[lIndex].length - 1]; if(reqLists[lIndex].length==0){ if(refIndex=='0'){ vm["hastopbar"+refIndex] = true vm["slaveKey1"] = "" info = preInfo }else{ info = reqList[0] } } vm.areaLevel = info.areaLevel; vm.level = info.level; vm.area = info.area; vm.lowLevel = info.lowLevel; vm.areaTitle = info.areaTitle; vm["reqListLength"+index] = reqLists[lIndex].length+1 if(reqLists[lIndex].length==0 && refIndex=='0'){ vm.getData(false,3) }else{ vm.getData(false,index) } vm.$refs["tableRef_"+refIndex].changeTab({level:vm.level,lowlevel:vm.lowLevel}) //表格tab }, backClick0:function(){ var vm=this vm.backClickHandel(0,0,'0') }, backClick1:function(){ var vm=this vm.backClickHandel(1,1,'1') }, backClick2:function(){ var vm=this vm.backClickHandel(2,2,'2') }, //时间选择 changeDate: function () { var vm=this //搜索时,取消下转记录 vm.area=vm.initarea vm.areaLevel=vm.initareaLevel vm.areaTitle=vm.initareaTitle vm.level=vm.initlevel vm.lowLevel = vm.initlowLevel reqHistoryInit(vm) vm.getData(true) vm.initTable() }, //切换line showTab:function(ptab){ var vm=this setTimeout(function(){ EventBus.$emit("draw-line-chart", { panelName : "分级诊疗情况", quotaNames : vm.ltabList[ptab].names, xData : vm.ltabList[ptab].xDatas[0], yDatas : vm.ltabList[ptab].yDatas, colors : ["#17b3ec",'#FF9526'], nowlineid : 'lineChart'+ptab, noDateType: true, chartheight:"320", unit:"人", noshowDate:false, }); },300) }, backClick:function(){ var vm=this // if (reqList.length == 1) { history.go(-1); // } else { // var lastInfo = reqList[reqList.length-1] // if(lastInfo.index){ // var idx = lastInfo.index - 8 // vm["backClick"+idx]() // } // } }, bindEvent:function(){ var vm=this //监听后退按钮的操作 EventBus.$on("back-click", function (arg) { EventBus.$emit('update-statistics-time', {}); //更新统计时间 vm.backClick() }); //监听页面刷新 EventBus.$on("refresh-click", function (arg) { EventBus.$emit('update-statistics-time', {}); //更新统计时间 initData(vm) }); //弹出筛选框 EventBus.$on('filter-click', function(arg) { //弹框显示筛选条件 Vuedals.Bus.$emit('new', { title: '条件筛选', onClose:function(data){ vm.chooseYear = data.chooseYear; if(vm.chooseYear){ vm.selDateType = undefined vm.end = getEndDate(vm.chooseYear) vm.start = getStartDate(vm.chooseYear) }else{ vm.selDateType = "按"+data.dimensionVal vm.end = getDateBefore(0) if(data.dimensionVal == '日'){ vm.start = getDateBefore(1) }else if(data.dimensionVal == '周'){ vm.start = getDateBefore(7) }else if(data.dimensionVal == '月'){ vm.start = getDateBefore(30) } } vm.rhfs = data.rhfs vm.pageIndex = data.smfu vm.pageIndex == 1?vm.appname="上门服务":vm.appname="入户访视" vm.changeDate() EventBus.$emit('update-statistics-time', {});//更新统计时间 //更新维度名称 EventBus.$emit('update-dimension-name', { "dimensionVal" : vm.selDateType }); }, component: 'smfw-filter', props: { chooseYear: vm.chooseYear, minYear:2016, dimensionValList:['日','周','月'], } }); }); $("#main").removeClass("c-hide"); }, initTable:function(){ var vm=this var tabList = [{name:"各区",level:"4",lowlevel:"3",isShow:true},{name:"社区",level:"3",lowlevel:"4",isShow:true},{name:"团队",level:"2",lowlevel:"5",isShow:true}] var tabList1 = JSON.parse(JSON.stringify(tabList)) vm.$refs.tableRef_1.initTable({ //表格表头 tabList:tabList1, headers:[{thead:"地区",param:"name",canclick:true},{thead:"服务工单(个)",param:"num"},{thead:"服务费用(元)",param:"price"}], tabnumber:vm.tabnumber, }) vm.$refs.tableRef_2.initTable({ //表格表头 tabList:tabList1, headers:[{thead:"地区",param:"name",canclick:true},{thead:"访视量",param:"num"}], tabnumber:vm.tabnumber, }) var tabItem = {name:"服务项目"} tabList.splice(3-vm.tabnumber,0,tabItem) vm.$refs.tableRef_0.initTable({ //表格表头 tabList:tabList, headers:[{thead:"服务项目",param:"name"},{thead:"服务次数(次)",param:"num"},{thead:"服务费用(元)",param:"price"}], tabnumber:vm.tabnumber+1, }) }, gotoServerList:function(){ var vm = this var hreftext = httpRequest.server+"ichat-web/#/service-order-List?roleCode="+vm.area //"http://192.168.131.103:8080/" + vm.hreftext +"?roleCode="+vm.area window.open(hreftext) //弹框显示筛选条件 // Vuedals.Bus.$emit('new', { // title: '服务工单记录', // onClose:function(data){ // }, // component: 'iframe-page', // props: { // hreftext: hreftext, // }, // size:'w90' // }); }, } }) function initData(vm) { //获得缓存中缓存的角色权限 var userRole = window.sessionStorage.getItem("selectedRole"); if (!userRole) { return false; } vm.userRole = JSON.parse(userRole); //level:2、市,3、区,4、社区,5、团队 vm.initareaLevel = vm.areaLevel = vm.userRole.code == '350200' ? 2 : vm.userRole.code.length == 6 ? 3 : 4; vm.initlevel = vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2; vm.initlowLevel = vm.lowLevel = vm.userRole.code == '350200' ? 3 : vm.userRole.code.length == 6 ? 4 : 5; vm.initarea =vm.area = vm.userRole.code; vm.initareaTitle = vm.areaTitle = vm.userRole.name; vm.tabnumber=vm.areaLevel==4?1:vm.areaLevel==3?2:3 //表格显示的tab数 //初始化时间 vm.chooseYear = getSignDate() vm.selDateType = undefined vm.end = getEndDate(vm.chooseYear) vm.start = getStartDate(vm.chooseYear) vm.changeDate() } function reqHistoryInit(vm){ reqList = [] reqLists = [[],[],[],[]] _.each(reqLists,function(item,idx){ var index = 8+idx vm["reqListLength"+index] = item.length+1 }) vm.slaveKey1_1 = "" vm.slaveKey1_2 = "" vm.hastopbar1 = true vm.hastopbar2 = true } function initReqParams(vm) { var reqParam = [{ url: "/doctor/statisticAnalyze/doorServiceOrderLowlevelAll", //服务项目分析(下转) reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 lowLevel:vm.lowLevel, //等级 1:团队 2社区机构 3区级 4市级 slaveKey1:vm.slaveKey1, }, },{ url: "/doctor/statisticAnalyze/doorServiceOrderLowlevelAll", //服务项目排名分析 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 lowLevel:vm.lowLevel, //等级 1:团队 2社区机构 3区级 4市级 slaveKey1:'', }, },{ url: "/doctor/statisticAnalyze/generalLowlevelAll", //入户访视-访视量排行 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 slaveKey1:vm.rhfs, index:vm.index, lowLevel:vm.lowLevel, //等级 1:团队 2社区机构 3区级 4市级 }, },{ url: "/doctor/statisticAnalyze/doorServiceItemAnalysis", //服务项目分析 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 pageSize:999, }, },{ url: "/doctor/statisticAnalyze/doorServiceAnalysis", //总体分析 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 }, },{ url: "/doctor/statisticAnalyze/serviceOrderTrend", //新增服务工单趋势 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 interval:1, }, },{ url: "/doctor/statisticAnalyze/getHomeVisitTotalHead", //入户访视-总体分析 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 slaveKey1:vm.rhfs, }, },{ url: "/doctor/statisticAnalyze/generalSingleLineChartTrend", //入户访视-访视量新增趋势 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 interval:1, slaveKey1:vm.rhfs, index:vm.index }, },{ url: "/doctor/statisticAnalyze/generalPieChartTrend", //入户访视-访视人群分析 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 slaveKey1:vm.rhfs, index:vm.index }, }]; return reqParam; } function loadData(loadArr, vm) { //获取其他请求的参数 var reqParams = initReqParams(vm), reqPromise = [], newArr = []; //记录非顶部请求的请求数组 for (i = 0; i < loadArr.length; i++) { var j = loadArr[i]; var param = reqParams[j]; reqPromise.push(httpRequest.get(param.url, { data: param.data })); newArr.push(loadArr[i]); } vm.isloading=true if (reqPromise.length > 0) { Promise.all(reqPromise).then(function (ress) { var res1, res2, res3, res4, res5, res6, res7, res8, res9; for (var i = 0; i < loadArr.length; i++) { var j = loadArr[i] + 1; if (j == 1) { res1 = ress[i]; } if (j == 2) { res2 = ress[i]; } if (j == 3) { res3 = ress[i]; } if (j == 4) { res4 = ress[i]; } if (j == 5) { res5 = ress[i]; } if (j == 6) { res6 = ress[i]; } if (j == 7) { res7 = ress[i]; } if (j == 8) { res8 = ress[i]; } if (j == 9) { res9 = ress[i]; } } if(res1&& res1.status == 200){ vm.tabledata0=listHandle(res1.data.index_177,"num"); } if(res2&& res2.status == 200){ vm.tabledata1=listHandle(res2.data.index_177,"num"); } if(res3&& res3.status == 200){ vm.tabledata2=listHandle(res3.data,"num"); } if(res4&& res4.status == 200){ vm.tabledata0=listHandle(res4.data,"num"); } if(res5&& res5.status == 200){ vm.pageData=res5.data vm.data0=_.map(vm.pageData.doorServiceTypeList,function(item,index){ return { code:item.code, amount:item.num, name:item.name, } }) vm.data1=_.map(vm.pageData.voucherList,function(item,index){ return { code:item.code, amount:item.num, name:item.name, } }) pieChartShow(vm,0) pieChartShow(vm,1) } if (res6 && res6.status == 200) { var data1={} data1.serviceOrderTrend = res6.data handleSecondPanelData(data1 ,1, vm) } if(res7&& res7.status == 200){ vm.pageData2=res7.data } if (res8 && res8.status == 200) { var data2={} data2.serviceOrderTrend = res8.data handleSecondPanelData(data2 ,2, vm) } if(res9&& res9.status == 200){ vm.data2=_.map(res9.data,function(item,index){ return { code:item.code, amount:item.num, name:item.name, } }) pieChartShow(vm,2) } vm.isloading=false }) } } function pieChartShow(vm,index){ if(vm['data'+index].length==0||(vm['data'+index].length==1&&!vm['data'+index][0].name)){ vm["pieShow"+index]=false }else{ vm["pieShow"+index]=true } setTimeout(function(){ //服务人群分析-饼图 handlePieData({elId:"pieChart"+index,arry: vm['data'+index], title:{},colors: colors,position:['25%', '45%'],radius:['61%', '90%'],hasNum:true,legendRight:"7%"}) },100) } function handleSecondPanelData(data,index, vm) { var xDatas = [], yDatas = [], names = [] for(var p in data){ names.push(vm.ltabList[index].indexNames[p]); xData = _.map(data[p], function(o){ return o.range; }); yData = _.map(data[p], function(o){ return o.amount; }); xDatas.push(xData); yDatas.push(yData); } vm.ltabList[index].xDatas = xDatas vm.ltabList[index].yDatas = yDatas vm.ltabList[index].names = names vm.showTab(index) } function listHandle(list, sort){ var topArr = [],newList=[]; if(list.length==1&&!list[0].name){ list=[] } topArr = soreRank(getKeyValueArr(list, sort||'total')); newList = _.map(list, function(o, index){ o.rank=topArr[index] return o }); return newList }