var reqList = []; //记录请求的参数和url,用于后退时使用 var pieChart1, pieChart2; //全局设置饼图的对象,window.resize时,触发chart的resize方法 Vue.use(Vuedals.default); new Vue({ el: "#main", data: { appname: "健康管理分析", isback: true, isrefresh: true, isfilter: true, isopen: true, //请求页面所需参数 level: '', area: '', areaTitle: '', index: '21', selectedDateType: 1, endDate: '', startDate: '', lowLevel: '', chooseYear: '', userRole: '', //数据结果 topDatas: { index_149: 0, index_21: 0, }, //微信绑定统计数据 wxTotal:{ label: '', amount1: '', //已缴费人数 amount2: '', //未缴费人数 rate: ''//绑定率 }, isloading:false, //加载中 }, components: { vuedals: Vuedals.Component }, methods: { changeTag: function(val){ this.index = val; loadData([1,2], this); //存储请求所带的参数 reqList.push({ level: this.level, area: this.area, areaTitle: this.areaTitle, index: this.index, endDate: this.endDate, startDate: this.startDate, lowLevel: this.lowLevel }) }, getNewLineData: function(arg){ this.selectedDateType = arg.dateType; loadData([1], this); }, getAreaData: function(arg){ //如果level改变,则需要重新加载整个页面的数据,否则只需加载底部区域数据 if(arg.level == this.level){ this.lowLevel = arg.lowLevel; loadData([2], this); }else{ this.level = arg.level; this.lowLevel = arg.lowLevel; this.area = arg.area; this.areaTitle = arg.areaTitle; loadData([0,1,2], this); } EventBus.$emit('update-area-name', {areaName: this.areaTitle}); //存储请求所带的参数 reqList.push({ level: this.level, area: this.area, areaTitle: this.areaTitle, index: this.index, endDate: this.endDate, startDate: this.startDate, lowLevel: this.lowLevel, selectedDateType: this.selectedDateType }) } }, mounted: function(){ //初始化数据 initData(this); //获得顶部各tab的值 loadData([0,1,2], this); //参数组数表示请求的区域为上中下 //存储请求所带的参数 reqList.push({ level: this.level, area: this.area, areaTitle: this.areaTitle, index: this.index, endDate: this.endDate, startDate: this.startDate, lowLevel: this.lowLevel, selectedDateType: this.selectedDateType }); //设置监听器, 监听折线图日期变化 var vm = this; //监听后退按钮的操作 EventBus.$on("back-click", function(arg){ EventBus.$emit('update-statistics-time', {}); //更新统计时间 if(reqList.length == 1){ history.go(-1); } else{ var preInfo = reqList.pop(); var info = reqList[reqList.length - 1]; vm.level = info.level; vm.area = info.area; vm.areaTitle = info.areaTitle; vm.lowLevel = info.lowLevel; vm.index = info.index; loadData([0,1,2], vm); EventBus.$emit('update-area-name', {areaName: vm.areaTitle}); } }); //监听页面刷新 EventBus.$on("refresh-click", function(arg){ loadData([0,1,2], vm); }); //弹出筛选框 EventBus.$on('filter-click', function(arg) { //弹框显示筛选条件 Vuedals.Bus.$emit('new', { title: '条件筛选', onClose:function(data){ vm.chooseYear = data.chooseYear; vm.startDate = getStartDate(vm.chooseYear); vm.endDate = getEndDate(vm.chooseYear); //请求参数重置,页面类型重新开始 vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2; vm.area = vm.userRole.code; vm.areaTitle = vm.userRole.name; EventBus.$emit('update-area-name', {areaName: vm.areaTitle}); vm.selectedDateType = 1; //然后清空请求列表数组 reqList.splice(0, reqList.length); loadData([0, 1, 2], vm);//刷新数据 //存储请求所带的参数 reqList.push({ level: vm.level, area: vm.area, areaTitle: vm.areaTitle, index: vm.index, endDate: vm.endDate, startDate: vm.startDate, lowLevel: vm.lowLevel, selectedDateType: vm.selectedDateType }); EventBus.$emit('update-statistics-year', {selectDate: vm.chooseYear + "年"});//更新年份 EventBus.$emit('update-statistics-time', {});//更新统计时间 }, component: 'year-filter', props: { selectedYear: vm.chooseYear } }); }); $("#main").removeClass("c-hide"); window.onresize = function() { if(pieChart1){ pieChart1.resize(); } if(pieChart2){ pieChart2.resize(); } window.lineCharts.resize(); //日周月折线图 } } }) function initData(vm){ //获得缓存中缓存的角色权限 var userRole = window.sessionStorage.getItem("selectedRole"); if(!userRole){ return false; } vm.userRole = JSON.parse(userRole); vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2; vm.area = vm.userRole.code; vm.areaTitle = vm.userRole.name; EventBus.$emit('update-area-name', {areaName: vm.areaTitle}); var now = new Date(); if(now.getMonth() >= 6){ vm.chooseYear = now.getFullYear(); }else{ vm.chooseYear = now.getFullYear() - 1; } vm.startDate = getStartDate(vm.chooseYear); vm.endDate = getEndDate(vm.chooseYear); EventBus.$emit('update-statistics-year', {selectDate: vm.chooseYear + "年"}); } function initReqParams(vm){ //增量(咨询量3、随访量4、健康教育5、代预约量27),到达量(绑定微信21、绑定设备20) if(vm.index == '149' || vm.index == '21'){ url2 = "statistics/interval_total"; url3 = "statistics/lowlevel_all"; } reqParam = [{ url: url2, data:{ index: vm.index, level: vm.level, area: vm.area, startDate: vm.startDate, endDate: vm.endDate, interval: vm.selectedDateType } },{ url: url3, data: { index: vm.index, level: vm.level, area: vm.area, sort: 1, year: vm.chooseYear } },{ //如果是微信绑定,则增加置顶展示当面层级的总绑定率及已缴费 未缴费居民数.只针对微信绑定时使用 url: '/statistics/getLevelTotalSingle', data: { date: vm.endDate, level: vm.level, area: vm.area } }]; if(vm.index == '149' || vm.index == '21' ){ reqParam[1].data.date = vm.endDate; }else{ reqParam[1].data.endDate = vm.endDate; } if(vm.lowLevel){ reqParam[1].data.lowLevel = vm.lowLevel; } return reqParam; } function getTopReqParams(index1, vm){ var url = "statistics/total", data = { index: index1, level: vm.level, area: vm.area, year: vm.chooseYear, endDate: vm.endDate, startDate: vm.startDate }; if(index1 == '149' || index1 == '21'){ url = "statistics/index_all"; } return { url: url, data: data }; } function getTopTagDatas(vm){ var reqs = [], indexs = ['21', '149']; for(i=0; i -1){ getTopTagDatas(vm); } vm.isloading=true //获取其他请求的参数 var reqParams = initReqParams(vm), reqPromise = [], newArr = []; //记录非顶部请求的请求数组 for(i=0; i 0){ Promise.all(reqPromise).then(function(ress){ vm.isloading=false var res2, res3, res4; for(var i=0; i